nanotube
July 6th, 2006, 12:43 PM
This is a quick howto on using rdiff-backup (available in official repositories as package rdiff-backup) on Ubuntu. rdiff-backup lets you make backups of your files, and conserves disk space by storing only the differences between new and old files. See the homepage of rdiff-backup here: http://www.nongnu.org/rdiff-backup/
This howto will show you how to quickly make backups to an external usb disk (rdiff-backup is also capable of making backups over the net, through ssh, but that is not what I do, and I figure that will hold for desktop users.)
1. Install rdiff-backup by running commands:
sudo aptitude update
sudo aptitude install rdiff-backup
2. Create an rdiff-backup script that will store your options, for ease of use (and for possible automation). My script is as follows:
#!/bin/bash
sudo /usr/bin/rdiff-backup --exclude /tmp --exclude /var/log --exclude /mnt --exclude /media --exclude /proc --exclude /sys --exclude /var/cache/apt --exclude /home/dfolkins/.Trash --exclude /data/.Trash-dfolkins --exclude /data/Documents / /media/usbdisk/dfolkins_backup/
Lets look at the details of the command. First comes sudo (because i am backing up everything, not just my user files), then comes rdiff-backup itself. Then, we have a bunch of --exclude statements, that exclude the directories you don't want to back up. The only one that you really need to exclude is /proc, everything else i just exclude because i don't need it. after that, comes your source dir (just / for me), and your destination dir (/media/usbdisk/dfolkins_backup for me). so it will take everytihng from /, and shove it onto that usbdisk, with the exception of the directories that are excluded.
3. Name the text file something like "rdiff-backup-script.sh", save it somewhere, say in your home directory, and make it executable by running
chmod u+x rdiff-backup-script.sh
4. Preparing the usb disk. Usually a new drive (or an old one) will be formatted with fat32. The problem with fat32 is that it has no capability to store permissions, so rdiff-backup may give you errors. If you are just backing up your personal data files, and not the whole system, fat32 may be ok, but for whole-system backups, you need to create an ext3 partition on your disk. If the disk currently has no data on it, you can just resize or delete the fat32 partition, and make an ext3 (using, for example, gparted partition editor, which you can install from the repositories.) If you already have data on your disk that you don't want to lose, then you have to be careful about moving things around (look around on these forums about repartitioning hard drives).
The next thing to do with the disk is to create a directory that you will use as the target for your backups, and make sure your user can write to it (give it the right permissions).
5. now, just run the command with
./rdiff-backup-script.sh
and sit back and wait. The first time around it will take you longer, since it copies everything over. subsequent backups will take much less time, since it only copies the diffs.
This howto will show you how to quickly make backups to an external usb disk (rdiff-backup is also capable of making backups over the net, through ssh, but that is not what I do, and I figure that will hold for desktop users.)
1. Install rdiff-backup by running commands:
sudo aptitude update
sudo aptitude install rdiff-backup
2. Create an rdiff-backup script that will store your options, for ease of use (and for possible automation). My script is as follows:
#!/bin/bash
sudo /usr/bin/rdiff-backup --exclude /tmp --exclude /var/log --exclude /mnt --exclude /media --exclude /proc --exclude /sys --exclude /var/cache/apt --exclude /home/dfolkins/.Trash --exclude /data/.Trash-dfolkins --exclude /data/Documents / /media/usbdisk/dfolkins_backup/
Lets look at the details of the command. First comes sudo (because i am backing up everything, not just my user files), then comes rdiff-backup itself. Then, we have a bunch of --exclude statements, that exclude the directories you don't want to back up. The only one that you really need to exclude is /proc, everything else i just exclude because i don't need it. after that, comes your source dir (just / for me), and your destination dir (/media/usbdisk/dfolkins_backup for me). so it will take everytihng from /, and shove it onto that usbdisk, with the exception of the directories that are excluded.
3. Name the text file something like "rdiff-backup-script.sh", save it somewhere, say in your home directory, and make it executable by running
chmod u+x rdiff-backup-script.sh
4. Preparing the usb disk. Usually a new drive (or an old one) will be formatted with fat32. The problem with fat32 is that it has no capability to store permissions, so rdiff-backup may give you errors. If you are just backing up your personal data files, and not the whole system, fat32 may be ok, but for whole-system backups, you need to create an ext3 partition on your disk. If the disk currently has no data on it, you can just resize or delete the fat32 partition, and make an ext3 (using, for example, gparted partition editor, which you can install from the repositories.) If you already have data on your disk that you don't want to lose, then you have to be careful about moving things around (look around on these forums about repartitioning hard drives).
The next thing to do with the disk is to create a directory that you will use as the target for your backups, and make sure your user can write to it (give it the right permissions).
5. now, just run the command with
./rdiff-backup-script.sh
and sit back and wait. The first time around it will take you longer, since it copies everything over. subsequent backups will take much less time, since it only copies the diffs.