9.4. rdiff backup server

There is a backup module included in Webmin. You find it under the tab "Servers" and "Skolelinux Backup", or https://tjener.intern:10000/slbackup

Warning

You should try running a few restores from your backup before it becomes seriously necessary.

Figure 9-1. Webmin Servers

This is the place in Webmin where you find slbackup.

Figure 9-2. Slbackup, General

Slbackup has 5 modes of operation;

Figure 9-3. Slbackup, Backup Details

This is where you set the time that you want the backup to be done, which will then take place at that time every day.

Figure 9-4. Slbackup, Backup Details, Backup Clients

Here you configure which machine you want to backup. You specify the IP address,or use the hostname, together with the directories that you want to backup, and how long you want to keep a copy of the backup.

Figure 9-5. Slbackup, Backup Details, Backup Server

Here you set up the details for the machine that is going to do the backup. The most important detail is where the backup is going to be stored. The default backup partition is the LVM partition /skole/backup, see section Section 8.5.3. But there is nothing to stop you from setting in an extra hard drive and storing your backup there instead.

If you are observant, you may have noticed that we place the backup on the same hard drive as the one we take backup of. Stupid? Not so, if we take backups as an extra service for our users in case they accidentally delete a file. It is, of course, stupid to store your backup on the same hard drive if the purpose is to guard against a drive getting broken. Then it is wiser to set up a machine with a workstation profile, see Section 2.5, and install some really large capacity hard drives and use slbackup to make the backup external..

Figure 9-6. Slbackup, Restore

What good is it to have a backup utility, if you can't put the files back that have been deleted? By choosing "Restore" you have the possibility to choose which machine you want to get the files from, as well as which file or entire directory you want to get. You can also use everything that you have taken a backup of on the machine in question.

Figure 9-7. Slbackup, Restored Files

When you have chosen which machine you want to get the backup from, then you will get to make several more choices, among which the date/time you want to restore the backup and where you want the files to be placed. To start with, it's wise to use the directory /tmp/<machinename>.

It's smart to place the files being restored in the directory /tmp/<machinename>. Everything that is stored in this directory gets deleted when the machine reboots. In addition, by placing the files there, in this temporary directory, you make sure that you don't accidentally write over the wrong files (when you replace an old file with a new one that has the same name). After you have taken out the files that you need to restore, then you must go into this directory, /tmp/<machinename>, and use a file manager, see Section 12.1, to get out the files that you want.

Figure 9-8. Slbackup, Maintenance

By choosing "maintenance" you get the possibility to delete old backups that you no longer have any use for, or place for.

Figure 9-9. Slbackup, SSH Keys

In order to be able to take a backup over the network from other machines, without being asked each time for a password, SSH has been set up in such a way so that you only type in the password once. See ssh for more about ssh.

9.4.1. Comparison of Various Versions of the Same File

If you have "destroyed" the format of a file, for example /etc/fstab but you know that you have a backup of that file which is good, then you can use on of several programs to compare the various versions of that file. If you have chosen to restore, then the old version of the file /etc/fstab will be placed in the directory /tmp/<machinename>/etc/fstab. A command-line based program is included to do a comparison of the files. The program is called diff, and is used in this fashion

diff /etc/fstab /tmp/<machinename>/etc/fstab

In this example, I have two examples of the file fstab, There is an error in one of them- it has two spellingmistakes.. This is the result of running the command diff with these two files:


tjener:~# diff /etc/fstab /tmp/tjener/etc/fstab
7,8c7,8
< /dev/vg_data/lv_home  /skole/tjener/home0     ext3    defaults        0 2
< /dev/vg_data/lv_bakup /skole/backup   ext3    defaults        0 2
---
> /dev/vg_data/lv_home0 /skole/tjener/home0     ext3    defaults        0 2
> /dev/vg_data/lv_backup        /skole/backup   ext3    defaults        0 2
Fortunately there are other programs that do the same job. One of them kompare can be installed with

apt-get install kompare

see
Section 8.9 for how to add new packages. kompare has a graphical interface (GUI). If I start kompare and open the two files in this program, this is what I see:

9.4.2. Dedicated machine to hold the backups

By setting up a machine with a "workstation",profile Section 2.5, and installing the necessary rdiff-applications, you can quickly set up a very user-friendly and powerful backup machine.

apt-get install rdiff-backup


ltspserver05:~# apt-get install rdiff-backup --simulate
Reading Package Lists... Done
Building Dependency Tree... Done
The following extra packages will be installed:
  librsync1 rdiff
The following NEW packages will be installed:
  librsync1 rdiff rdiff-backup
0 upgraded, 3 newly installed, 0 to remove and 119 not upgraded.
Inst librsync1 (0.9.7-1 Debian:3.1r0/stable)
Inst rdiff (0.9.7-1 Debian:3.1r0/stable)
Inst rdiff-backup (0.13.4-5 Debian:3.1r0/stable)
Conf librsync1 (0.9.7-1 Debian:3.1r0/stable)
Conf rdiff (0.9.7-1 Debian:3.1r0/stable)
Conf rdiff-backup (0.13.4-5 Debian:3.1r0/stable)
ltspserver05:~# apt-get install rdiff-backup
Reading Package Lists... Done
Building Dependency Tree... Done
The following extra packages will be installed:
  librsync1 rdiff
The following NEW packages will be installed:
  librsync1 rdiff rdiff-backup
0 upgraded, 3 newly installed, 0 to remove and 119 not upgraded.
Need to get 0B/197kB of archives.
After unpacking 770kB of additional disk space will be used.
Do you want to continue? [Y/n]
Selecting previously deselected package librsync1.
(Reading database ... 69270 files and directories currently installed.)
Unpacking librsync1 (from .../librsync1_0.9.7-1_i386.deb) ...
Selecting previously deselected package rdiff.
Unpacking rdiff (from .../rdiff_0.9.7-1_i386.deb) ...
Selecting previously deselected package rdiff-backup.
Unpacking rdiff-backup (from .../rdiff-backup_0.13.4-5_i386.deb) ...
Setting up librsync1 (0.9.7-1) ...

Setting up rdiff (0.9.7-1) ...
Setting up rdiff-backup (0.13.4-5) ...
When combined with making a backup volume, see Section 8.5.8, this is a fine way to do backups of files all the time.

To add a dedicated backupvolume, run this command

lvcreate --size 1G --name lv_backup vg_system
mkdir /backup
mke2fs -j /dev/vg_system/lv_backup

Don't forget to add a corresponding entry in /etc/fstab in this case it would be

/dev/vg_system/lv_backup  /backup          ext3    defaults                0       2

Warning

You must make sure that this machine has a locked ip-address, have a look at dhcp-server

Also make sure that you under the tab Backup details specify that the backup-server it external and remember to use the correct ip-address in the field Hostname or IP-address:, you could also stick with using the hostname backup, provided that you have made the correct changes to the DNS server, see DNS

9.4.3. Slbackup from the Command Line

There are commands that can be run from the command line, so you don't need to start a webbrowser and Webmin.

The command to list times backup is available from

rdiff-backup --list-increments tjener::/skole/backup/tjener

If you have the backups placed on a external machine, like described in then substitute "tjener" with the hostname or ip-address of that machine, and the path to where you have placed the backups, it might look like this:

rdiff-backup --list-increments 10.0.2.50::/backup/tjener

Note

If you are logged in on the machine that holds the backup, you don't need to specify any hostname/ip-address, if you are logged in on the fileserver, you could just use

rdiff-backup --list-increments /skole/backup/tjener


tjener:~# rdiff-backup --list-increments tjener::/skole/backup/tjener/
Password:
-----------------------------------------------------------------
Detected abilities for archive (read/write) file system:
  Characters needing quoting                   ''
  Ownership changing                           On
  Hard linking                                 On
  fsync() directories                          On
  Directory inc permissions                    On
  Access control lists                         Off
  Extended attributes                          Off
  Mac OS X style resource forks                Off
  Mac OS X Finder information                  Off
-----------------------------------------------------------------
Found 13 increments:
    increments.2005-09-24T22:45:23+02:00.dir   Sat Sep 24 21:45:23 2005
    increments.2005-09-25T22:45:22+02:00.dir   Sun Sep 25 21:45:22 2005
    increments.2005-09-26T22:48:25+02:00.dir   Mon Sep 26 21:48:25 2005
    increments.2005-09-27T22:45:23+02:00.dir   Tue Sep 27 21:45:23 2005
    increments.2005-09-28T22:48:23+02:00.dir   Wed Sep 28 21:48:23 2005
    increments.2005-09-29T23:15:18+02:00.dir   Thu Sep 29 22:15:18 2005
    increments.2005-09-30T23:14:56+02:00.dir   Fri Sep 30 22:14:56 2005
    increments.2005-10-01T23:14:07+02:00.dir   Sat Oct  1 22:14:07 2005
    increments.2005-10-02T23:13:02+02:00.dir   Sun Oct  2 22:13:02 2005
    increments.2005-10-03T23:14:12+02:00.dir   Mon Oct  3 22:14:12 2005
    increments.2005-10-04T23:14:58+02:00.dir   Tue Oct  4 22:14:58 2005
    increments.2005-10-06T00:00:44+02:00.dir   Wed Oct  5 23:00:44 2005
    increments.2005-10-06T23:56:50+02:00.dir   Thu Oct  6 22:56:50 2005
Current mirror: Fri Oct  7 22:59:53 2005

If you now want to restore some files, say from the date 2005-10-04T23:14:58 the files in /etc/network/interfaces and place them in /tmp/intefaces you could use

rdiff-backup --restore-as-of 2005-10-04T23:14:58 tjener::/skole/backup/tjener/etc/network/interfaces /tmp/interfaces

If you rather have the newest available file from the backup, you use the keyword "now" for date, like this

rdiff-backup --restore-as-of now tjener::/skole/backup/tjener/etc/network/interfaces /tmp/interfaces

9.4.4. Slbackup Log Files

You find the log files for slbackup in /var/log/slbackup/slbackup.log. This is where information is logged about when the last backup was done, how much was changed, etc

--------------[ Session statistics ]--------------
StartTime 1086202803.00 (Wed Jun  2 21:00:03 2004)
EndTime 1086204514.88 (Wed Jun  2 21:28:34 2004)
ElapsedTime 1711.88 (28 minutes 31.88 seconds)
SourceFiles 56607
SourceFileSize 1625082476 (1.51 GB)
MirrorFiles 41244
MirrorFileSize 1060012665 (1011 MB)
NewFiles 15372
NewFileSize 564463215 (538 MB)
DeletedFiles 9
DeletedFileSize 65488 (64.0 KB)
ChangedFiles 344
ChangedSourceSize 667575185 (637 MB)
ChangedMirrorSize 666903101 (636 MB)
IncrementFiles 15725
IncrementFileSize 1936873 (1.85 MB)
TotalDestinationSizeChange 567006684 (541 MB)
Errors 0
--------------------------------------------------

Jun 02 21:28:36 - Successfully finished backing up client tjener
Jun 02 21:28:36 - Finished slbackup.
It pays once in a while to have a look at this file, check that you have "Successfully finished backing up"

9.4.5. Use of slbackup in real-life

Go to Restore and choose "full restore", make sure you have enough space in the directory where you place the files temporarily. If there is something wrong with your backup, you'll find out now.