Loading...
 

Greg's Tech blog

Linux Backups

Wednesday 25 of April, 2012

Found a backup script and modified it - see below. The script is saved in /etc/cron.weekly and shoud run 4:30 every Sunday or Monday (Day 0) The tape device is /dev/nst0 -

  1. !/bin/bash
  1. Create backups of /etc, /home, /usr/local, and...

PATH=/bin:/usr/bin tape="/dev/nst0" backupdirs="/etc /root /boot /home /usr/local /var/lib /var/log /var/www/htdocs"

  1. Make MySQl Dump
echo "Dumping mysql databases"
mysqldump password=M@ddexit  flush-logs --opt tiki > /usr/local/MySqlDumps/tikidb
echo "Dumping tiki database"
mysqldump password=M@ddexit flush-logs --opt mysql > /usr/local/MySqlDumps/mysqldb
echo "Dumping mysql admin database"
echo "Rewinding tape"
mt -f $tape rewind for path in $backupdirs do echo "System backup on $path" tar cf $tape $path 1>/dev/null sleep 2 done
echo "System backups complete, status: $?"
echo "Now verifying system backups"
mt -f $tape rewind for path in $backupdirs do echo "Verifying $path...." tar tf $tape 1>/dev/null && \ echo "$path: verified"
echo "$path: errors in verify"
if $? -eq 0 then echo "$path: verified"
else
echo "$path: error(s) in verify" 1>&2 fi mt fsf 1 done
mt -f $tape rewoffl
echo "Please remove backup tape" | wall