Backup on Linux - with backup2l
A while ago we bought an 80GB external usb harddisk for storing backups. After tediously archiving the files by hand for a couple of months we finally decided to look for a tool to do incremental backup for us automatically.
First, a look at the limitations of our old methods for dumping the filesystem: using tar or dump.
tar
- It doesn’t support multiple volumes with file output (with -M option, it overwrites the file) - that was our 4GB limitation with FAT32 partition
- I don’t know how to handle differential backups efficienly
- No automation
dump
- Works only on ext2/3 filesystems
- Incremental backups are trivial (based on the date only)
- Little automation
Having a quick look at what’s available in debian repositories we found a nice little tool called backup2l. It’s essentially just a shell script, but is just what we needed.
It’s as simple as install, configure and run. We changed the following main configuration options and left the rest to default.
# list of directories to backup
SRCLIST=(/etc /root /home /var/ /usr/local /work /packages /usr/src/config /mnt/shared/work /mnt/shared/mail /mnt/shared/drivers)
# Mount point of backup device
BACKUP_DEV="/mnt/backup"
# backup directory
BACKUP_DIR="/mnt/backup/orta-backup"
# uncomment the following to backup installed packages in debian
echo " writing dpkg selections to /root/dpkg-selections.log..."
dpkg --get-selections | diff - /root/dpkg-selections.log > /dev/null || dpkg --get-selections > /root/dpkg-selections.log
#UNCONFIGURED=1
CREATE_DRIVER=DRIVER_TAR
Create the mount point for the backup drive if haven’t already done so,
/dev/sda1 /mnt/backup reiserfs rw,noauto 0 0
backup2l can also mount the external mountpoint automatically, which is great, although it doesn’t work for us - our USB drive has a problem: if the usb_storage module was loaded before we connect the external storage it may not work, so need to rmmod usb_storage first then plug it again.
To backup just run,
$ backup -b [backup level]
It looks at existing repositories and performs an incremental backup at a given level or a full backup. The repositories are updated accordingly.
To restore files run,
$ backup -r [pattern]
It is also posssible to restore files at a given time with the -t option.
backup2l also installs a cron script to /etc/cron.daily/zz-backup2l. Comment out if you don’t want to run scheduled backups, which is true in our case since the backup drive is not always connected.
One Response to “Backup on Linux - with backup2l”
Leave a Reply
You must be logged in to post a comment.
December 4th, 2004 at 1:00 pm
If you cannot easily access the drive that you wish to store the backup on (the drive is on another computer) you have several options. One is to use a script like above, but mount the remote directory to your local file system. Many ways are available to do this: NFS, Samba, SHFS, etc.
Another option (that I have just begun using) is hdup — http://www.miek.nl/projects/hdup16/ . It can work locally (just like the script above) but it can also work remotely and save the backup on any remote host that you can SSH to. I need to test with another restore, but so far the backups are working quite well.
There are Debian packages availible for Testing and Unstable:
http://packages.debian.org/cgi-bin/search_packages.pl?searchon=names&version=all&exact=1&keywords=hdup
For MySQL backups it is hard to beat automysqlbackup –> http://sourceforge.net/projects/automysqlbackup/ .
My $0.02
Sam