Created
March 2, 2016 14:15
-
-
Save pedro108/42e00a1b24a983d9fc2b to your computer and use it in GitHub Desktop.
This file contains 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
password="#{database_password}" | |
database_name="#{database_name}" | |
file_name=Dump_${database_name}_$(date +%d%m%Y_%H%M) | |
mkdir -p ~/backups && cd ~/backups | |
mysqldump -u root -p$password $database_name > $file_name.sql | |
tar czfv $file_name.tar.gz $file_name.sql | |
rm $file_name.sql | |
# Remove backups older than 15 days | |
find ~/backups -type f -mtime +15 -exec rm -f {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment