Database Backup

#!/bin/sh
2now="$(date +'%d_%m_%Y_%H_%M_%S')"
3filename="db_backup_$now".gz
4backupfolder="/var/www/vhosts/example.com/httpdocs/backups"
5fullpathbackupfile="$backupfolder/$filename"
6logfile="$backupfolder/"backup_log_"$(date +'%Y_%m')".txt
7echo "mysqldump started at $(date +'%d-%m-%Y %H:%M:%S')" >> "$logfile"
8mysqldump --user=mydbuser--password=mypass --default-character-set=utf8 mydatabase | gzip > "$fullpathbackupfile"
9echo "mysqldump finished at $(date +'%d-%m-%Y %H:%M:%S')" >> "$logfile"
10chown myuser "$fullpathbackupfile"
11chown myuser "$logfile"
12echo "file permission changed" >> "$logfile"
13find "$backupfolder" -name db_backup_* -mtime +8 -exec rm {} ;
14echo "old files deleted" >> "$logfile"
15echo "operation finished at $(date +'%d-%m-%Y %H:%M:%S')" >> "$logfile"
16echo "*****************" >> "$logfile"

17exit 0