PgSync: Sync Postgres data between databases
github.com
github.com
- Handles MySQL -> pg; MSSQL -> pg; And pg -> pg copy
- Very fast (lisp/"real threading")
- Syncs schemas effectively (this says data only)
- Has it's own DSL for batch jobs: specify tables to include/exclude, renaming them on the fly in dest, and cast dtypes between src and dest if needed. etc
I tried migrating a smallish mysql database (~10Gb) to postgres and it always crashed with a weird runtime memory error. Reducing the number of threads or doing it table by table didnt help.
I've used pgloader multiple times because I'm a huge Postgres evangelist for that exact use case multiple times without issue. Honestly - it's a favorite tool in my toolbox.
If it's "heap exhausted, game over", there's a solution for that - you need to tell pgloader to allocate more memory for itself.
It's worth getting it going, it's one of the greatest tools in migrating things into and out of pgsql I've ever used. If you have pgsql in your pipeline, get it working.
I used this and debezium to really make my ETL pipeline absolutely bulletproof.
This looks very cool, was not aware of it:
"Debezium is a set of distributed services that capture row-level changes in your databases so that your applications can see and respond to those changes."
https://github.com/ankane/pgsync/blob/master/lib/pgsync/tabl...
https://www.postgresql.org/docs/10/logical-replication.html
This isn't rsync style two way sync, though, it's more for one way streaming / ongoing replication, although you could technically set up a master-master or replication chain if the conflicts are dealt with correctly.
I never did find a solution I could live with. I'm trying to start that project back up right now.
It appears not to use logical decoding/replication. If so, how it does sync the data? It sounds like a hard problem, and not very efficient, to do it without logical decoding/replication.
I didn't see documentation about it. Unless.. it is intended to be used only with offline databases.
And "batch one-way sync" is better described as "copy".
So I think this is a "postgres database copy" tool. Also known as clone, or backup. And as such, it's competing with the existing postgres database cloning tools, like pg_dump. So how is this different than that?
The primary use case for this appears to be ETL. Pg_dump is more backup-oriented and optimized for larger operations, vs. a bit more fine-grained in most ETL processes.
It needs temp tables.
I spent a few hours trying all of the options in this thread and I couldn't find anything that also transferred functions and triggers which was vital for my project.
Here is a little bash file that I whipped together to completely wipe the DB and import it in.
https://gist.github.com/nickreese/8eeb01e2f73fec2bf2dbfecf5d...
Just have the variables in your .env file and it will wipe your local DB and copy from production.
Need user where id = 64418362 and associated orders, order_items, etc
Done in like 5 seconds
I am excited to try this and see if it might be a better way to pull in what's needed.
BTW: Awesome work ankane! Cool dude too :)