InstalaciónInstall
Compile desde el código fuente con el SDK de .NET 10. El binario resultante se llama dbfsync.exe.
Build from source with the .NET 10 SDK. The resulting binary is called dbfsync.exe.
CompilarBuild
git clone https://github.com/peopleworks/DBFSync.git
cd DBFSync
dotnet publish src/DBFSync/DBFSync.csproj `
--configuration Release `
--runtime win-x86 `
--self-contained false `
--output dist/win-x86CI también publica este artefacto en cada push: descárguelo desde la pestaña Actions.
CI publishes this artifact on every push too — download it from the Actions tab.
RequisitosRequirements
- Windows
- x86 o x64 (proceso de 32 bits)x86 or x64 (32-bit process)
- ODBC
- Microsoft Visual FoxPro ODBC Driver (x86)Microsoft Visual FoxPro ODBC Driver (x86)
- .NET 10
- Runtime en destino, SDK para compilarRuntime on target, SDK to build
# verificar instalaciónverify install
dbfsync --version
dbfsync --help
dbfsync sampleInicio rápido con SQLiteSQLite quick start
SQLite no requiere servidor ni credenciales: es el destino recomendado para la primera prueba. El archivo y sus carpetas padre se crean solos.
SQLite needs no server and no credentials — the recommended destination for a first run. The file and its parent folders are created automatically.
# 1 · crear el perfil y el archivo SQLitecreate the profile and the SQLite file
dbfsync profile set local `
--engine sqlite `
--file C:\DBFSync\erp.db
# 2 · revisar qué se leeráreview what will be read
dbfsync inspect `
--source C:\ERP\Datos `
--tables "clientes,articulos,fa*.dbf" `
--exclude "*hist*,*bak*"
# 3 · carga inicialinitial load
dbfsync migrate `
--profile local `
--source C:\ERP\Datos `
--tables "clientes,articulos,fa*.dbf"
# 4 · sincronizaciones posterioressubsequent synchronizations
dbfsync sync `
--profile local `
--source C:\ERP\Datos `
--tables "clientes,articulos,fa*.dbf" `
--sync-schemaPerfiles y seguridadProfiles and security
Un perfil guarda motor, servidor, base, esquema y usuario. La contraseña se protege con DPAPI y nunca viaja en los argumentos.
A profile stores engine, server, database, schema, and user. The password is protected with DPAPI and never travels in the arguments.
PostgreSQL — SSL verificadoverified SSL
dbfsync profile set erp-pg `
--engine postgresql `
--server pg01.example.com `
--port 5432 `
--database erp `
--schema public `
--user dbfsync `
--create-databaseSQL Server — autenticación WindowsWindows authentication
dbfsync profile set erp-mssql `
--engine sqlserver `
--server sql01 `
--database ERP `
--schema dbo `
--integratedAdministrarManage
dbfsync profile list
dbfsync profile show erp-pg
dbfsync profile test erp-pg
dbfsync profile remove erp-pgshow nunca imprime la contraseña.
show never prints the password.
Contraseña desatendidaUnattended password
# lee una línea desde stdinreads one line from stdin
"s3cr3t" | dbfsync profile set erp-pg `
--engine postgresql `
--server pg01.example.com `
--database erp `
--user dbfsync `
--password-stdinOpciones de profile setprofile set options
| OpciónOption | MotoresEngines | DescripciónDescription |
|---|---|---|
--engine | pg · mssql · sqlite | Requerido: postgresql, sqlserver o sqliteRequired: postgresql, sqlserver, or sqlite |
--server | pg · mssql | Servidor o dirección IPServer or IP address |
--port | pg · mssql | Puerto; PostgreSQL usa 5432 si se omitePort; PostgreSQL uses 5432 when omitted |
--database | pg · mssql | Base de datosDatabase |
--file | sqlite | Archivo de base SQLiteSQLite database file |
--schema | pg · mssql | Predeterminado public o dboDefaults to public or dbo |
--user | pg · mssql | Usuario cuando no se usa autenticación integradaUser when integrated authentication is not used |
--integrated | mssql | Usa la identidad Windows del procesoUses the process Windows identity |
--scope | pg · mssql | Ámbito DPAPI user o machine; predeterminado userDPAPI scope user or machine; defaults to user |
--no-encrypt | pg · mssql | Desactiva SSL / deja de exigir cifrado. Solo desarrollo local confiableDisables SSL / stops requiring encryption. Trusted local development only |
--trust-server-certificate | pg · mssql | Mantiene el cifrado sin validar el certificadoKeeps encryption without validating the certificate |
--password-stdin | pg · mssql | Lee una línea desde stdin en vez de preguntarReads one line from stdin instead of prompting |
--create-database | todosall | Crea la base o el archivo si no existeCreates the database or file when missing |
--no-encrypt desactiva la protección del transporte. Úselo únicamente contra un servidor local de confianza, nunca sobre una red compartida.
--no-encrypt turns off transport protection. Use it only against a trusted local server, never over a shared network.
Crear la baseCreate the database
Crea o verifica la base del perfil. Idempotente: si ya existe, lo informa y termina con éxito.
Creates or verifies the profile database. Idempotent: if it already exists it reports so and exits successfully.
dbfsync database create --profile erp-pg
# aliases equivalentesequivalent aliases
dbfsync db ensure --profile erp-pg
dbfsync base crear --profile erp-pg--profile es la única opción aceptada por este comando.
--profile is the only option this command accepts.
Inspeccionar antes de escribirInspect before writing
Muestra esquema, filas activas y una muestra de datos sin tocar el destino. No necesita perfil.
Shows schema, live rows, and a data sample without touching the destination. No profile needed.
dbfsync inspect `
--source C:\ERP\Datos `
--tables "fa*.dbf" `
--exclude "*hist*"
# toda la carpetathe whole folder
dbfsync inspect --source C:\ERP\Datos --allinspect solo acepta --source, --tables, --table, --exclude y --all. Es de solo lectura.
inspect accepts only --source, --tables, --table, --exclude, and --all. It is read-only.
Migrar y sincronizarMigrate and synchronize
Ambos comparten las mismas opciones. La diferencia está en qué hacen con el contenido que ya existe en el destino.
Both share the same options. The difference is what they do with content that already exists in the destination.
migrate — carga inicialinitial load
Reemplaza el contenido del destino. Es el punto de partida de una tabla.
Replaces the destination content. It is a table's starting point.
dbfsync migrate `
--profile erp-pg `
--source C:\ERP\Datos `
--tables "clientes,articulos" `
--batch-size 5000sync — reconciliaciónreconciliation
Inserta nuevos, actualiza cuando cambia el SHA-256 y elimina los ausentes o marcados como borrados.
Inserts new rows, updates when the SHA-256 changes, and deletes rows that are absent or flagged as deleted.
dbfsync sync `
--profile erp-pg `
--source C:\ERP\Datos `
--tables "clientes,articulos" `
--sync-schemaOpciones de transferenciaTransfer options
| OpciónOption | DescripciónDescription |
|---|---|
--profile | Perfil destino. RequeridoDestination profile. Required |
--source | Carpeta con los DBF. RequeridoFolder holding the DBFs. Required |
--tables | Nombres o patrones separados por comaComma-separated names or patterns |
--table | Patrón individual; puede repetirseSingle pattern; may be repeated |
--all | Todos los DBF de la carpetaEvery DBF in the folder |
--exclude | Excluye nombres o patronesExcludes names or patterns |
--batch-size | Filas por lote; predeterminado 5000, rango 1–100000Rows per batch; defaults to 5000, range 1–100000 |
--sync-schema | Aplica evolución estructural seguraApplies safe structural evolution |
--allow-drop-columns | Autoriza eliminar columnas; exige --sync-schemaAuthorizes dropping columns; requires --sync-schema |
--recreate | Reconstruye las tablas; solo migrateRebuilds the tables; migrate only |
Selección de DBFDBF selection
Los patrones usan * y ?. La extensión .dbf es opcional y las exclusiones se aplican al final.
Patterns use * and ?. The .dbf extension is optional and exclusions are applied last.
Formas de seleccionarWays to select
# lista separada por comacomma-separated list
--tables "clientes,articulos,fa*.dbf"
# opción repetidarepeated option
--table "fa*" --table "cbmovf??"
# toda la carpeta menos lo excluidowhole folder minus exclusions
--all --exclude "*hist*,*bak*,tmp?"ComodinesWildcards
- *
- Cualquier cantidad de caracteresAny number of characters
- ?
- Exactamente un carácterExactly one character
- fa*.dbf
- Todo lo que empieza con
faEverything starting withfa - cbmovf??
cbmovf+ dos caracterescbmovf+ two characters
--all y los patrones de inclusión son mutuamente excluyentes.
--all and inclusion patterns are mutually exclusive.
Evolución del esquemaSchema evolution
Sin --sync-schema, una diferencia estructural detiene la tabla en vez de adivinar. Los cambios destructivos exigen autorización explícita.
Without --sync-schema, a structural difference stops the table instead of guessing. Destructive changes require explicit authorization.
SeguroSafe
Agrega campos nuevos y amplía tipos compatibles.
Adds new fields and widens compatible types.
dbfsync sync `
--profile erp-pg `
--source C:\ERP\Datos `
--all `
--sync-schemaDestructivoDestructive
Eliminar columnas o reconstruir la tabla borra datos del destino.
Dropping columns or rebuilding the table deletes destination data.
# eliminar columnas ausentes en el DBFdrop columns missing from the DBF
dbfsync sync … --sync-schema --allow-drop-columns
# reconstruir desde cero (solo migrate)rebuild from scratch (migrate only)
dbfsync migrate … --recreate--allow-drop-columns exige --sync-schema. Ninguna de las dos es reversible.
--allow-drop-columns requires --sync-schema. Neither one is reversible.
AutomatizaciónAutomation
La tarea programada solo recibe el nombre del perfil: nunca necesita la contraseña.
The scheduled task only receives the profile name — it never needs the password.
Task Scheduler
$action = New-ScheduledTaskAction `
-Execute "C:\Tools\PeopleWorks\DBFSync\dbfsync.exe" `
-Argument 'sync --profile erp-pg --source C:\ERP\Datos --tables "fa*.dbf" --lang es'
$trigger = New-ScheduledTaskTrigger -Once `
-At (Get-Date).AddMinutes(1) `
-RepetitionInterval (New-TimeSpan -Minutes 5)
$settings = New-ScheduledTaskSettingsSet `
-MultipleInstances IgnoreNew -StartWhenAvailable
Register-ScheduledTask -TaskName "PeopleWorks DBFSync ERP" `
-Action $action -Trigger $trigger -Settings $settings--scope user la tarea debe correr con la misma cuenta que creó el perfil. Con --scope machine, limite el acceso NTFS a la carpeta de configuración.
With --scope user the task must run under the same account that created the profile. With --scope machine, restrict NTFS access to the configuration folder.
Códigos de salidaExit codes
0 | Ejecución correctaSuccessful run |
1 | Argumentos inválidos, error de conexión o transferenciaInvalid arguments, connection or transfer error |
130 | Cancelación con Ctrl+CCancelled with Ctrl+C |
Trate únicamente el 0 como éxito.
Treat only 0 as success.
Rutas y variablesPaths and variables
- DBFSYNC_LANG
- Idioma de la CLI (
es/en)CLI language (es/en) - DBFSYNC_HOME
- Carpeta de configuración y logsConfiguration and log folder
# predeterminadosdefaults
C:\ProgramData\PeopleWorks\DBFSync\profiles.json
C:\ProgramData\PeopleWorks\DBFSync\logs\
# idioma sin argumentoslanguage without arguments
$env:DBFSYNC_LANG = "es"Los logs registran progreso, conteos y errores, pero nunca contraseñas.
Logs record progress, counts, and errors, but never passwords.
ChuletaCheat sheet
Todos los comandos y sus aliases. --lang (o --language) puede aparecer en cualquier posición.
Every command and its aliases. --lang (or --language) can appear at any position.
| ComandoCommand | Aliases | Qué haceWhat it does |
|---|---|---|
dbfsync --help | -h · help · ayuda | Ayuda resumidaSummary help |
dbfsync --version | -v · version | VersiónVersion |
dbfsync sample | samples · example · ejemplo(s) | Escenarios completosFull scenarios |
profile set NAME | perfil guardar | Crea o reemplaza un perfilCreates or replaces a profile |
profile list | perfil listar | Lista perfilesLists profiles |
profile show NAME | perfil mostrar | Muestra un perfil sin secretosShows a profile without secrets |
profile test NAME | perfil probar | Prueba la conexiónTests the connection |
profile remove NAME | delete · perfil eliminar | Elimina un perfilRemoves a profile |
database create | db · base · ensure · crear · asegurar | Crea o verifica la baseCreates or verifies the database |
inspect | inspeccionar | Esquema, filas activas y muestraSchema, live rows, and sample |
migrate | migrar | Reemplaza el contenido destinoReplaces destination content |
sync | synchronize · sincronizar | Reconcilia altas, cambios y bajasReconciles inserts, updates, and deletes |