Sync data between Postgres databases
masterUse the pgsync command to transfer data. By default, it syncs all tables defined in your configuration.
Common Sync Commands:
- Sync all tables:
pgsync - Sync specific tables:
pgsync table1,table2 - Sync using wildcards:
pgsync "table*" - Sync specific rows (overwrites existing):
pgsync products "where store_id = 1" - Sync specific rows (preserves existing):
pgsync products "where store_id = 1" --preserve - Sync specific rows (truncates existing):
pgsync products "where store_id = 1" --truncate - Sync in batches (for large append-only tables):
pgsync large_table --in-batches(requires a numeric, increasing primary key)
Note: To avoid accidentally overwriting production, the destination is limited to localhost or 127.0.0.1 by default. To allow other hosts, set to_safe: true in your .pgsync.yml.
pgsync