Created
April 25, 2015 00:28
-
-
Save KhanMaytok/1abdad62c95b3f7993e0 to your computer and use it in GitHub Desktop.
Backup Mysql
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/sh | |
now="$(date +'%d_%m_%Y_%H_%M_%S')" | |
filename="db_backup_$now".gz | |
backupfolder="/home/ubuntu/backups" | |
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=root --password=password --default-character-set=utf8 bd_vitekey_cloud | gzip > "$fullpathbackupfile" | |
echo "mysqldump finished at $(date +'%d-%m-%Y %H:%M:%S')" >> "$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