Skip to content

Instantly share code, notes, and snippets.

@mkusher
Last active August 29, 2015 14:03
Show Gist options
  • Save mkusher/fec25503925cd361663e to your computer and use it in GitHub Desktop.
Save mkusher/fec25503925cd361663e to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
DUMP_DIR="/var/www/dumps"
cur_date=`date +%Y.%m.%d`
file=$(printf "dump.%s.sql" "$cur_date")
archive=$(printf "%s.gz" "$file")
mysqldump --host=%% --user=%% --password=%% % > $DUMP_DIR/$file
gzip -cf $DUMP_DIR/$file > $DUMP_DIR/$archive
rm $DUMP_DIR/$file
old_date=`date +%Y.%m.%d -d "10 days ago"`
old_file=$(printf "dump.%s.sql.gz" "$old_date")
rm $DUMP_DIR/$old_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment