Backup Website Data w/ MySQL

From Michael's Information Zone
Revision as of 15:05, 17 May 2016 by Michael.mast (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
#!/bin/bash
date=$(date +%Y-%m-%d)
olddate=$(date --date="1 week ago" +%Y-%m-%d)
mysqldump --all-databases -p<DBPassword> /root/dbbackup/database_$date.sql
rm -f /root/dbbackup/database_$olddate.sql
cp -r /root/webbackup /root/sitebackup/daily_$date
rsync -av --delete /var/www /root/webbackup/
rm -f /root/sitebackup/daily_%olddate

####The following is for managing disk space, will be visited later.
#df -lh /dev/sda2 --output=ipcent > /tmp/percent
#grep '^ ' /tmp/percent > /tmp/percent1
#rm /tmp/percent
#disk=$(sed 's/^\ \ \ //' /tmp/percent1)
#diskused=$(sed 's/%//' < $disk)
#unset disk
#if ( $diskused <= 10 ); then
#rm /root/old/*