Last active
July 27, 2021 16:19
-
-
Save orendon/11300678 to your computer and use it in GitHub Desktop.
pg_dump pg_restore postgresql backup postgres
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create and restore backups on PostgreSQL (tested on 9.2 and 9.3) | |
# create database backup | |
PGPASSWORD="XXX" pg_dump --no-owner --no-acl -U USER DATABASE -h HOST -F t > output_file.tar | |
# create database backup (heroku) | |
heroku pgbackups:capture | |
heroku pgbackups # show stored backups (assuming a117 is the desired one) | |
heroku pgbackups:url a117 # => it retrieves dump url on AWS S3 | |
# upload dump to server | |
scp ~/Downloads/filename.dump user@remoteserver:~/destination_path | |
# restore backup | |
pg_restore -d DATABASENAME /tmp/path_to_filename.dump |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brew install postgres | |
initdb /usr/local/var/postgres | |
createuser -s postgres | |
psql -U postgres |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment