Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # myugan59@gmail.com
- # CRED
- DB_USER="user"
- DB_PASS="user"
- DB_NAME="dbname"
- # PATH/DIR
- SRCDIR="/path/to/backups"
- EXPDIR="$SRCDIR/$DB_NAME_$(date +"%H%M-%d-%m-%Y").sql"
- # Dump db to local
- mysqldump -u$DB_USER -p$DB_PASS $DB_NAME > $EXPDIR
- # Compress db
- tar -zcvf $EXPDIR.tar.gz $EXPDIR
- # Cleanup db after 30 days
- find $SRCDIR -maxdepth 1 -type f -iname '*.sql' -mtime +30 -print0 | xargs -0 rm -f
- find $SRCDIR -maxdepth 1 -type f -iname '*.tar.gz' -mtime +30 -print0 | xargs -0 rm -f
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement