Backup Website Data w/ MySQL
Revision as of 15:01, 17 May 2016 by Michael.mast (talk | contribs) (Created page with "<syntaxhighlight lang="BASH"> #!/bin/bash date=$(date +%Y-%m-%d) olddate=$(date --date="1 week ago" +%Y-%m-%d) mysqldump --all-databases -p<DBPassword> /root/dbbackup/database...")
#!/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 /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/*