Created
April 19, 2018 19:21
-
-
Save lucasmontec/7e8c3c5a8c4cab9047d86828a5a187ec to your computer and use it in GitHub Desktop.
mariadb (mysql) autobackup for linux
This file contains hidden or 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/bash | |
NOW="$(date +%Y%m%d%H%M%S)" | |
FILENAME="${NOW}" | |
echo "[INFO] Backup Started" | |
echo "[INFO] Filename : bckp_${FILENAME}.db" | |
mkdir -p backups/ | |
#Remove files older than 4 days | |
find ~/backups -mtime +3 -type f -delete | |
BACKUPCOMMAND="mysqldump -u user --password=password --quick --single-transaction --lock-tables=false $ | |
eval $BACKUPCOMMAND | |
echo "[INFO] Backup Finish!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment