Created
November 27, 2017 19:32
-
-
Save corentingi/6229d82d2907a41eb2f4dc508e098a27 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 | |
| # Taken from https://simon-davies.name/bash/backing-up-mysql-databases | |
| # Database credentials | |
| user="" | |
| password="" | |
| host="" | |
| db_name="" | |
| # Other options | |
| backup_path="/path/to/your/home/_backup/mysql" | |
| date=$(date +"%d-%b-%Y") | |
| # Set default file permissions | |
| umask 177 | |
| # Dump database into SQL file | |
| mysqldump --user=$user --password=$password --host=$host $db_name > $backup_path/$db_name-$date.sql | |
| # Delete files older than 30 days | |
| find $backup_path/* -mtime +30 -exec rm {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment