pgsync truncate records even using --preserve tag
Closed this issue · 1 comments
Hi,
I'm trying to sync my table with the day's records, but pgsync is deleting records from previous days.
How to synchronize without deleting the other records? I'm using --preserve, but the records are still deleted.
First of all. I make restore the entire database to ensure that all records are in both databases. Then i program cron job at night, to syncronize both databases.
I using that:
To sync schema first
pgsync --from postgres://postgres:aaaaa@localhost:5432/$database --to postgres://postgres:aaaa@targeHost:5432/$database --to-safe --schema-only
Then, i sync all tables excluding the table with i want sync day records
pgsync --from postgres://postgres:aaaa@localhost:5432/$database --to postgres://postgres:aaaaa@targeHost:5432/$database --disable-integrity --to-safe --exclude=mensagens --preserve
Sync only table with day records
pgsync mensagens "where cast(data as date) = current_date" --preserve --from postgres://postgres:aaa@localhost:5432/$database --to postgres://postgres:aaa@targetHost:5432/$database --disable-integrity --to-safe
But in second step, when do that, pgsync truncated records the another days.
OBS: The table mensagens is a large table.
Can u please, help me. Please
Hi @telmedola, syncing the schema (step 1) deletes existing data. You'll need to use a schema migration tool to avoid this.