Created
August 29, 2023 21:54
-
-
Save kfelter/2289fd48533ffc4c7d97bfaba77d3b7d to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
FNAME="$(date +"%Y_%m_%d_%H_%M_%S").dump" | |
/opt/homebrew/bin/mysqldump --port=3306 --host=127.0.0.1 \ | |
-u $your_username -p$your_password $your_database_name > $FNAME | |
gzip $FNAME | |
# Then, you can add a cron job to run this script every day at 3am: | |
# 0 3 * * * /path/to/backup-db.sh | |
# restore db | |
# gzcat BACKUP_FILE_GZIP | mysql --port=3306 --host=127.0.0.1 -u $your_username -p $your_database_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment