Created
July 31, 2018 11:08
-
-
Save Karolass/2515c48395c4ce2061fd899bddc265f2 to your computer and use it in GitHub Desktop.
mysql backup
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
#!/bin/sh | |
DBUSER=ooo | |
DBPASS=xxx | |
DBNAME=db | |
DAYS=7 | |
DEST=/path/your/folder | |
DATE=`date +%Y%m%d` | |
mkdir -p $DEST | |
echo "Remove old over $DAYS SQL files" | |
find $DEST -name '*.sql' -mtime "+$DAYS" -exec rm {} \; | |
echo "Backup Databases to SQL file" | |
mysqldump -u$DBUSER -p$DBPASS $DBNAME > $DEST/$DBNAME-$DATE.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment