Last active
August 29, 2015 13:57
-
-
Save johnbeynon/9887761 to your computer and use it in GitHub Desktop.
Backup commands for MySQL and Postgres - backs up all databases!
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
# backup_all_dbs.sh | |
# Expects ~/backups to exist | |
# Expects pg to be running on 127.0.0.1 | |
# Expects mysql to be running on 127.0.0.1 | |
# Expects mysql root user to have no password | |
# Expects zip to be available. | |
echo "Backing up local DBs" | |
pg_dumpall -h 127.0.0.1 > ~/backups/postgres.sql | |
mysqldump -u root --all-databases > ~/backups/mysql.sql | |
echo "Remove existing backups" | |
rm ~/backups/postgres.zip | |
rm ~/backups/mysql.zip | |
echo "ZIP new backups" | |
cd ~/backups | |
zip postgres.zip postgres.sql | |
zip mysql.zip mysql.sql | |
echo "Remove .sql files" | |
rm postgres.sql | |
rm mysql.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment