Created
July 13, 2014 11:23
-
-
Save wopfel/babe646a47d79753cb1e to your computer and use it in GitHub Desktop.
Backup script for MariaDB (or MySQL). Placed in /etc/cron.hourly/. Creates a backup of all databases every hour and keeps the current plus nine previous versions.
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/bash | |
BASENAME="/var/backups/MySQL-Backup.gz" | |
x=9 | |
rm "$BASENAME.$x" | |
while [ $x -gt 1 ] | |
do | |
y=$(( $x - 1 )) | |
mv "$BASENAME.$y" "$BASENAME.$x" | |
x=$(( $x - 1 )) | |
done | |
mv "$BASENAME" "$BASENAME.1" | |
umask 0027 | |
# Seit 26.04.2013 kommt ohne "--events" die Meldung: | |
# Warning: Skipping the data of table mysql.event. Specify the --events option explicitly. | |
/usr/bin/mysqldump --all-databases --events --password=PASSWORD --user=root --host=localhost \ | |
| gzip --stdout \ | |
> "$BASENAME" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment