Simple Backup using rsync

How are you using your Bubba Two or Excito B3? Got pictures? Share here!
Post Reply
Posts: 31
Joined: 27 Jun 2010, 06:20

Simple Backup using rsync

Post by beeversf » 23 Nov 2013, 03:01

I have been for a while using SyncToy a windows utility for incrementally backing up across the network from Bubba 2 to a disk on the windows machine. This is understandably slow and requires my presence. However it does mean I can store a backup off site.

I have the requirement for an automatic backup of weekly for the main data and daily for the mail data. I looked with interest at the new backup and even tried to use a soft link (ln -s) so that I could use the /home/storage facility in the web front end but it did not work. I suspect a recursive issue. I then tried to decipher the web coding to see how to modify it but this seemed a little complicated and would be destroyed by an upgrade. I want to perform a mirror backup not an incremental backup so decided to write up a simple scheme.

So this is for those who want a starter for 10 to write their own. The next step will be to encrypt the solution.

I have a USB powered disk of the same size as the bubba 2. I re-formatted this disk to ext3. This is so that the mail backup will work as unique file names in UINX are quite long and NTFS file systems cannot really handle them. I use my pear based laptop for this. It also means you need a UNIX/LINUX machine to read them which has a little security but not much.Also the character encoding is correct which means rsync is more likely to work. Using rsync on different types of file systems has always led to problems.

working in root mode
I created a directory in storage called backup_files. In there I created files called backup_mail and backup_data and made them executable. Here is the file contents for backup_mail.

Code: Select all

DAY=`date "+%A"`
# copy Mail data
	echo "Start of Mail Backup `date`\n" > /home/storage/backup_files/mail$DAY.txt
	rsync -av --exclude fstab --delete /home/bubba/Mail/ /home/storage/extern/My_Passport_0741-1/backup/Mail/ >> /home/storage/backup_files/mail$DAY.txt
	echo "\nEnd of Mail Backup" >> /home/storage/backup_files/mail$DAY.txt
This copies the changes from the mail directory to the external drive and copies the output to a text file for perusal at a later date. Note the careful use of the / at the end of the directory reference. This is very important.
I then made an entry in the /etc/crontab file

Code: Select all

0 2  * * sun root /home/storage/backup_files/backup_data > /home/storage/backup_files/cronjob_data
0 4 * * * root /home/storage/backup_files/backup_mail > /home/storage/backup_files/cronjob_mail
The second line creates a daily backup at 4 am and the first a weekly back at 2 on a Sunday. I normally divert the output to a log file - no real reason just precautionary. I then re-started bubba. No reason I just always do when I make a system change. Please be warned - I have not fully tested the crontab addition - need a week of use first

Code: Select all

The file for the weekly backup is as follows:
DAY=`date "+%A"`
# copy Mail data
	echo "Start of Mail Backup `date`\n" > /home/storage/backup_files/mail$DAY.txt
	rsync -av --exclude fstab --delete /home/bubba/Mail/ /home/storage/extern/My_Passport_0741-1/backup/Mail/ >> /home/storage/backup_files/mail$DAY.txt
	echo "\nEnd of Mail Backup" >> /home/storage/backup_files/mail$DAY.txt

# copy Documents data
	echo "Start of Documents Backup `date`\n" > /home/storage/backup_files/Documents$DAY.txt
	rsync -av --exclude fstab --delete /home/storage/Documents/ /home/storage/extern/My_Passport_0741-1/backup/Documents/ >> /home/storage/backup_files/Documents$DAY.txt
	echo "\nEnd of Documents Backup" >> /home/storage/backup_files/Documents$DAY.txt

# copy film data
	echo "Start of film Backup `date`\n" > /home/storage/backup_files/film$DAY.txt
	rsync -av --exclude fstab --delete /home/storage/film/ /home/storage/extern/My_Passport_0741-1/backup/film/ >> /home/storage/backup_files/film$DAY.txt
	echo "\nEnd of film Backup" >> /home/storage/backup_files/film$DAY.txt

# copy music data
	echo "Start of music Backup `date`\n" > /home/storage/backup_files/music$DAY.txt
	rsync -av --exclude fstab --delete /home/storage/music/ /home/storage/extern/My_Passport_0741-1/backup/music/ >> /home/storage/backup_files/music$DAY.txt
	echo "\nEnd of music Backup" >> /home/storage/backup_files/music$DAY.txt

# copy No_backup data
	echo "Start of No_backup Backup `date`\n" > /home/storage/backup_files/No_backup$DAY.txt
	rsync -av --exclude fstab --delete /home/storage/No_backup/ /home/storage/extern/My_Passport_0741-1/backup/No_backup/ >> /home/storage/backup_files/No_backup$DAY.txt
	echo "\nEnd of No_backup Backup" >> /home/storage/backup_files/No_backup$DAY.txt

# copy pictures data
	echo "Start of pictures Backup `date`\n" > /home/storage/backup_files/pictures$DAY.txt
	rsync -av --exclude fstab --delete /home/storage/pictures/ /home/storage/extern/My_Passport_0741-1/backup/pictures/ >> /home/storage/backup_files/pictures$DAY.txt
	echo "\nEnd of pictures Backup" >> /home/storage/backup_files/pictures$DAY.txt

# copy video data
	echo "Start of video Backup `date`\n" > /home/storage/backup_files/video$DAY.txt
	rsync -av --exclude fstab --delete /home/storage/video/ /home/storage/extern/My_Passport_0741-1/backup/video/ >> /home/storage/backup_files/video$DAY.txt
	echo "\nEnd of video Backup" >> /home/storage/backup_files/video$DAY.txt

# copy videomp4 data
	echo "Start of videomp4 Backup `date`\n" > /home/storage/backup_files/videomp4$DAY.txt
	rsync -av --exclude fstab --delete /home/storage/videomp4/ /home/storage/extern/My_Passport_0741-1/backup/videomp4/ >> /home/storage/backup_files/videomp4$DAY.txt
	echo "\nEnd of videomp4 Backup" >> /home/storage/backup_files/videomp4$DAY.txt
The use of --exclude fstab is just a precautionary measure and can be excluded. I got caught out some years ago so always include this.

So there we have it. To restore off the mirror just copy and paste or rysnc the other way without the --delete flag.

For an offsite copy I currently use my pear laptop to rysnc from the usb mirror to the external drive ( ide in an external ide box) However I will purchase a eSATA external box when I have the time and connect that to the eSATA slot and thereby use the bubba to rysnc to the off-site disk.

Hope this is useful. Maybe our friends at Excito will extend their backup to allow the backup of various directories of our choice rather than the specific ones at the moment.

Post Reply