Skip to content

Instantly share code, notes, and snippets.

@osw4l
Last active August 3, 2021 23:27
Show Gist options
  • Save osw4l/0f7c37507a4f20d898b701b7268148ce to your computer and use it in GitHub Desktop.
Save osw4l/0f7c37507a4f20d898b701b7268148ce to your computer and use it in GitHub Desktop.
# heroku backup
heroku pg:backups:capture --app heroku_app_name
heroku pg:backups:download --app heroku_app_name
# when the latest.dump are downloaded
pg_restore --verbose --clean --no-acl --no-owner -h my_rds_host -U user -d db latest.dump
# download backup from remote database
pg_dump -h host -U user -C db --file=db_backup.dump
# rds backup
pg_dump -h host -Fc -U user db > db_backup.dump
# gzip rds backup
pg_dump -h host -Fc -U user db | gzip > file.gz
# load backup .gz in local
gunzip -c db.gz | pg_restore --verbose --clean --no-acl --no-owner -U user -d db -p 5432
# load backup .gz in remote host
gunzip -c db.gz | pg_restore --verbose --clean --no-acl --no-owner -h my_rds_host -U user -d db -p 5432
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment