Backup data from Bubba to external drive using Rsync

From BubbaWiki
Revision as of 21:02, 19 December 2010 by Asad (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Backup data from Bubba to external drive using Rsync

You can create a manual backup of all your data to an external drive. Online backup services may not be good because you never know who accesses your data or it is expensive and slow to backup large amounts of data.
Please note that you must have ntfs-3g installed in order to copy data to a hard drive with NTFS partition. You may also schedule this command using cron. This command will first run a full backup, and then run a differential backup, which means that if any file is added or deleted on the source, that change will also happen the next time the backup is run on the destination.

Warning: Remove the --delete-delay option if you want to keep old files on the destination that have been updated/changed on the source since the last time. Otherwise they will be removed.
If you don't need this option, it may just be better to use Bubbas built in backup feature.

It is recommended to keep an offline copy of your data and backup the changes once a week or when needed. Also be very careful with the paths, otherwise you may loose data!

First of all install Rsync and ntfs-3g. (only needed if you backup to NTFS partition)

apt-get install rsync
apt-get install ntfs-3g

Now, connect your external drive to Bubba and go to Disc Information in Bubba GUI to find the appropriate disk name and mount point. Click connect, go back to your shell

root@b3:/home/asqu# mount
/dev/sda1 on / type ext3 (rw,noatime)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
/dev/mapper/bubba-storage on /home type ext3 (rw)
usbfs on /proc/bus/usb type usbfs (rw)
/dev/sdc1 on /home/storage/extern/Expansion_Drive-1 type fuseblk (ro,allow_other,blksize=4096) //This is mounted read only by Bubba as default

Now, disconnect the drive from the web gui. Issue the following command: (In my case, the external seagate drive NTFS formatted is connected to the lower USB port). You should use eSATA cable for best transfer speed.

mount /dev/sdc1 /home/storage/extern/Expansion_Drive-1

Now, we are ready to backup, in my case all my data is stored on the folder "data" in the storage folder.

rsync -rav --delete-delay /path/to/source/ /path/to/destination/

rsync -rav --delete-delay /home/storage/data/ /home/storage/extern/Expansion_Drive-1/data/

Now, verify that the changed/updated files have been copied. If there is no data on destination, a new full backup is made.

You may now disconnect the drive from bubba web gui.

The following explanation can be found at: http://www.samba.org/ftp/rsync/rsync.html

-r, --recursive
This tells rsync to copy directories recursively. See also --dirs (-d).

-a, --archive
This is equivalent to -rlptgoD.
It is a quick way of saying you want recursion and want to preserve almost everything
(with -H being a notable omission).

-v, --verbose
This option increases the amount of information the daemon logs during its startup phase.

--delete-delay
Request that the file-deletions on the receiving side be computed during the
transfer (like --delete-during), and then removed after the transfer completes.

By default, rsync uses changed time and date, it is posssible to use checksum verification (-c option) of changed files which takes a much longer time to run the backup.

Example backup script which can be scheduled with cron to run every night:

#!/bin/bash
#Main backup to Disk 2 (Connected with USB/eSATA)
#We mount and umount the disk before backup for increased security in case of power loss
mount /dev/sdb1 /home/storage/extern/Ext_HDD_1021-1
rsync -vrav --delete-delay /home/user/data/ /home/storage/extern/nameofdrive/data/
umount /dev/sdb1

References: http://www.samba.org/ftp/rsync/rsync.html