Mysql Database Backup Script


#!/bin/bash
now=”$(date +’%d_%m_%Y_%H_%M_%S’)”
filename=”db_backup_$now”.gz
backupfolder=”/var/www/html/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 -u root -p databasename | gzip > “$fullpathbackupfile”
echo “mysqldump finished at $(date +’%d-%m-%Y %H:%M:%S’)” >> “$logfile”
exit 0

Path Details
Backup Path –> /var/www/html/backups (Ubuntu 14.04 & CentOS)
Backup Path –> /var/www/backups (Ubuntu 12.04)

Output Details
Web Interface
Ip-address/backups/ (Checking Your Data)

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s