I have a postgres database with 40 tables residing on Heroku right now. It's a Django app, and overall rows are roughly 5 million.
I want to migrate all that to an exact replica in an Azure VM (which already has postgres correctly installed and set up).
What's the safest, cleanest way to make this migration?
Here are the steps in my head:
1) Prepare the Azure VM, by:
switching to user postgres
and going to psql client via typing psql
creating a database called mydatabase
via the command CREATE DATABASE mydatabase;
no need to run syncdb
to create tables at this stage.
2) Log onto the Heroku commandline, and run the command heroku maintenance:on
3) Next, run the command heroku run pg_dump -C dbname | bzip2 | ssh myusername@hostname "bunzip2 | psql mydatabase"
heroku run pg_dump -C dbname | bzip2 | ssh myusername@hostname "bunzip2 | psql mydatabase"
heroku run pg_dump -C dbname | bzip2 | ssh myusername@hostname "bunzip2 | psql mydatabase"
(source: here )
That's it. No syncdb to create table structures or anything at any point.
Can anyone comment on those steps, and rectify wherever needed? Thanks!
Note: ask for more information in case you need it
heroku pg:backups capture
(to capture the pg backup)
curl -o latest.dump heroku pg:backups public-url
(to download the pg backup to your local machine)
ls -lh latest.dump
(to check the size of the downloaded file, so you're certain you downloaded the complete file)
scp -P <your port eg 2222> latest.dump user@example.cloudapp.net:/home/user
(this will transfer the file to your remote machine)
Then on your remote machine: pg_restore --verbose --clean --no-acl --no-owner -U myuser -d mydb latest.dump
Hopefully this gets the job done.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.