Last active
September 14, 2015 13:48
-
-
Save bonelifer/e477d82025514d9ba88f to your computer and use it in GitHub Desktop.
mysql weekly Backup Script
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 | |
now="$(date +'%d_%m_%Y_%H_%M_%S')" | |
filename="mysql-kodi_backup_$now".gz | |
backupfolder="/media/5a24e136-09b9-48e1-95db-b44d5db3e28a/Backup/mysql" | |
fullpathbackupfile="$backupfolder/$filename" | |
logfile="$backupfolder/"backup_log_"$(date +'%Y_%m')".txt | |
echo "mysqldump started at $(date +'%d-%m-%Y %H:%M:%S')" >> "$logfile" | |
mysqldump --user=xbmc --password=xbmc --default-character-set=utf8 --single-transaction --all-databases | gzip > "$fullpathbackupfile" | |
echo "mysqldump finished at $(date +'%d-%m-%Y %H:%M:%S')" >> "$logfile" | |
chown root "$fullpathbackupfile" | |
chown root "$logfile" | |
echo "file permission changed" >> "$logfile" | |
find "$backupfolder" -name db_backup_* -mtime +8 -exec rm {} \; | |
echo "old files deleted" >> "$logfile" | |
echo "operation finished at $(date +'%d-%m-%Y %H:%M:%S')" >> "$logfile" | |
echo "*****************" >> "$logfile" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment