Skip to content

Instantly share code, notes, and snippets.

@pedro108
Created March 2, 2016 14:15
Show Gist options
  • Save pedro108/42e00a1b24a983d9fc2b to your computer and use it in GitHub Desktop.
Save pedro108/42e00a1b24a983d9fc2b to your computer and use it in GitHub Desktop.
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