BackupPC: Backup Server

繁體中文版

In our school, like many other schools and organizations, backing up of one's data is at most an afterthought or maybe no backup is made at all. Until a disaster occurs, like one of your disks dies, and then you really begin to appreciate the value of backing up your data. Besides the nerve wrecking experience, to reconstruct your original data of may be a few months is very difficult and time consuming. Usually the reconstruction can never be 100%.

This year, our school wants to centralize our backup. So we have to build or buy a backup server. A proprietary backup server would cost over NT$200,000 (US$6,655) and that is a lot of money! Being familiar with Linux and opensource software, I was very sure that there should be an enterprise grade opensource backup software available in the Internet. After googling, three opensource backup solutions stand out: Amanda, Bacula and BackupPC. I decided on BackupPC as it is easier to install and is considered an enterprise grade backup solution. If this is viable, then the total cost of a backup server will be around NT$20,000 (US$665) for a new computer with about 4TB - 6TB harddisk. The software will cost us nothing!

I am using Fedora 20 as the backup server. Fedora 20's  BackupPC version is 3.3.0-2 and rsync version is 3.1.0-5. I will be using the rsyncd transfer method as this is the fastest way to backup. So, for the Windows XP client, I am using the latest free version of cwRsync and the rsync version is 3.1.1pre1.

I presume the following:

Domain

example.com

Linux BackupPC server backup.example.com 192.168.1.1
Windows XP backup client data.example.com 192.168.1.2

Server:

BackupPC requires that a httpd (Apache) server is already installed. If you do not have it, just install it:

yum install httpd

After this, you can install BackupPC:

yum install BackupPC

yum will also install all the files that BackupPC requires.

After the installation of BackupPC, a new user account backuppc:backuppc is created.

Edit /etc/httpd/conf.d/BackupPC.conf and add:

# Apache 2.4
<RequireAll>
    Require valid-user
    <RequireAny>
        Require local
        Require host example.com  <== Add this line so that all computers in your domain may connect to BackupPC.
    </RequireAny>
</RequireAll>

Create a user (backuppc) to manage BackupPC:

htpasswd -c /etc/BackupPC/apache.users backuppc

You will be asked for a password. When you connect to backup.example.com, you need to login as user backuppc and the password.

If you want to add another user, e.g., ben, to help you manage BackupPC, create the user name ben and the corresponding password:

htpasswd /etc/BackupPC/apache.users ben

Edit /etc/BackupPC/config.pl (I just changed the following):

$Conf{TopDir} = '/var/lib/BackupPC/'; ==> $Conf{TopDir} = '/backup/backuppc/';  <== change the location of the backup directories/files to /backup/backuppc
$Conf{PingPath} = ''; ==> $Conf{PingPath} = '/usr/bin/echo';

Edit /etc/BackupPC/hosts and add this line to the bottom:

data 0 backuppc ben

data the host name of the computer to be backed up (data.example.com)
0 using static IP
backuppc the manager for the backup data of host data
ben another manager for the backup data of host data. If you want to manage the host data alone, just omit the name ben

I partitioned my disk to:

/dev/sda1 /boot 1 GB should be enough space even if you use grub2 boot loader
/dev/sda2 / 50 GB Linux operating system
/dev/sda3 /backup The rest, less 10 GB for swap partition to put all backup data
/dev/sda4 swap 10 GB  

Since I wanted all the backup data to be located in /backup/backuppc/, go to /backup and make backuppc directory, change the permissions of backuppc and the owner to backuppc:backuppc (remember the user created after installing BackupPC?)

cd /backup
mkdir backuppc
chmod 750 backuppc
chown backuppc:backuppc backuppc

Now the server configuration is finished. You need to restart httpd and backuppc:

systemctl restart httpd
systemctl restart backuppc

Remove a host and its backup data

To completely remove a client and all its backups, you should remove its entry in conf/hosts (/etc/BackupPC/hosts) file, and then delete the __TOPDIR__/pc/$host directory (/backup/backuppc/pc/$host directory). Whenever you change the hosts file, you should send BackupPC a HUP (-1) signal so that it re-reads the hosts file. If you don't do this, BackupPC will automatically re-read the hosts file at the next regular wakeup.

Retire a host

If you want to stop backing up an old client machine but still want to keep the backup data in BackupPC you can disable the backups via the web interface

Select the host...
click on Edit Config
click on Schedule
activate Override and set BackupsDisable to "2"

Setting this to "1" allows manual backups to occur, "2" disables any backups.

Client (Windows XP)

Download cwRsync-5.3.0_Free.zip, Junction.zip, rsyncd.conf and rsyncd.secrets to c:\rsyncd.

Unzip cwRsync-5.30.0_Free.zip and Junction.zip to c:\rsyncd.

Create the file rsyncd.cmd with the contents below:

@echo off
c:\rsyncd\rsync --config=/cygdrive/c/rsyncd/rsyncd.conf --daemon

Edit rsyncd.conf:

use chroot = false
max connections = 2
lock file = c:/rsyncd/rsyncd.lock
[backup]    <== Module name
    path = /cygdrive/c/rsyncd/backup   <== symlink of direcotry d:\我的輩分
    comment = Description of the content of the backup
    strict modes = false
    auth users = backuppc   <== this is the user your created with htpasswd above
    secrets file = c:/rsyncd/rsyncd.secrets
    hosts allow = 192.168.1.1   <== allow the backup server to connect
    read only = false
    list = false

path =: If you want to backup the whole D:\ drive, then use path=/cygdrive/d/. But if you want to backup a particular directory and as long as you use pure ASCII characters for the directory name, then there is no problem. Using extended ASCII characters like the German Umlaut (Ü) or the French cedilla (Ç) creates a problem of not finding the directory. This means that any character with its 8th bit set will always have this problem. This is especially true here in Taiwan since the Windows XP in Taiwan is using the Traditional Chinese (BIG5), a 2 bytes, charset where the 8th bit of the first byte is always set. I think this is a software bug.

So what to do? junction.exe comes to the rescue! junction.exe creates something like a symlink which Linux users are very familiar with. Simply put, junction.exe creates an alias to a directory name or filename. In order not to clutter the directories and file structure of the backup client computer, I suggest to put all the symlinks in c:\rsyncd. As an example, I want to make a symlink  to a directory d:\我的備份 named backup, I would go to c:\rsyncd and then issue the command:

junction backup d:\我的輩份.

So the path item in rsyncd.conf should be path=/cygdrive/c/rsyncd/backup and everything will work without any problem.

Edit rsyncd.secrets:

Change #UUU:PPP ==> myname:mypassword

myname:mypassword will be used by the backup server to connect to the client machine for backing up..

cwRsync does not have the files rsyncd.conf and rsyncd.secrets. I took these 2 files from cygwin-rsyncd-3.0.9.0_source.zip. But I prefer to use the cwRsync over cygwin-rsyncd because cwRsync contains the latest version of rsync.exe and is very fast. All the files I have mentioned above are available for download in my ftp server.

Execute rsyncd.cmd and the Windows XP client for backup is ready and waiting for the server to connect. If you have the firewall enabled, a message will appear. Just allow and open the rsync port 873

To make sure that rsync is in fact running, press the key-combination Ctrl+Shift+Esc. This will display the Windows Task Manager. Click on Processes and you should be able to see rsync is listed there.

Now it is time to connect to backup.example.com web server for further configuration of BackupPC. Open your browser and type:

http://backup.example.com/backuppc

Input backuppc as user and the password. Then you will be connected to the Web interface of Backuppc. On the left panel click on Select a host... and choose host name (data). Click on Edit Config. Then click on Xfer and change the following:

XferMethod click on Override and then choose rsyncd as the transfer method.
ClientCharset leave empty
ClientCharsetLegacy click on Override and delete the content of the line (iso-8859-1).
RsyncShareName: click on Override and input the module name that you put in rsyncd.conf. The one inside the square bracket, i.e, backup.
RsyncdUserName click on Override and input the username, the username you use instead of UUU in rsyncd.secrets (myname).
RsyncdPasswd click on Override and input the password, the password you use instead of PPP in rsyncd.secrets (mypassword).

Click on Save above. Click on data home on the left panel. Then click on Start Full Backup. BackupPC will now connect to the Windows XP client and do a full backup.

According to the default backup schedule:

Full backup

Every 7 days, keep only newest copy

Incremental Backup Every day, keep the 6 most recent backups

Once you click Save, BackupPC will create a configuration file hostname.pl, i.e., data.pl, in /etc/BackupPC/pc/. So if you want to change the web interface to a different language, for example to French, add to /etc/BackupPC/pc/data.pl the line:

$Conf{Language} = 'fr';

BackupPC supports the following languages:

Czech (cz.pm), German (de.pm), English (en.pm), Spanish (es.pm), French (fr.pm), Italian (it.pm), Japanese (ja.pm), Netherland (nl.pm),
Polish (pl.pm), Portuguese Brazil (pt_br.pm), Russian (ru.pm), Ukrainian (uk.pm), Simplified Chinese, China (zh_CN.pm).

To make sure that c:\rsyncd\rsyncd.cmd is executed after booting the computer, add the command to the Startup folder:

1. Start --> Programs --> right click Startup folder --> open
2. File --> New --> Shortcut
3. Browse button --> click on the program to use, i.e., browse to c:\rsyncd and click on rsyncd.cmd
4. Next --> Finish (You should see the new shortcut in the Startup folder).
5. Next time you start your computer, the program will run automatically and can be seen in the system tray.

Here is a picture of a Windows XP Traditional Chinese (BIG5 charset) version client after a full backup. Obviously, I can not use the directory written in Chinese. So, I used junction.exe to make a symlink which I called backup:

Congratulations. You have now an enterprise grade backup server!

Once I have a Windows 7 computer available, I will experiment on how to set up a Windows 7 backup client. Until then, this article ends here.

Client (Windows 7)

2014/09/27: I finally got a hold of a Windows 7 computer. So I started experimenting on how to configure the Windows 7 backup client. The procedure is like Windows XP except that Windows 7 is much more restrictive even for the user (here I will use the username ben) who is also setup as an administrator. So there will be extra steps in configuring Windows 7.

Download all the files in my ftp server except Junction.zip since Windows 7 has an equivalent program called mklink. The files downloaded will usually be placed at the user's home directory: c:\users\ben\ under the directory download (c:\users\ben\download). Unzip cwRsync_5.3.0_Free.zip.

Now we will run Command Prompt with administrator privileges:

Start --> All Programs --> Accessories --> right click on Command Prompt --> click on Run as administrator.

Change to c:\ (root directory in c:). I still prefer to put all the client backup files in c:\rsyncd. So create a directory rsyncd and then copy all the necessary files:

cd \
mkdir rsyncd
cd rsyncd
copy c:\users\ben\download\rsyncd.*
copy c:\users\ben\download\cwRsync_5.3.0_Free\*

This time, I want to backup the directory d:\新資料夾-1. So I have to make the symlink I called win7backup:

mklink /J win7backup d:\新資料夾-1

Edit rsyncd.conf and rsyncd.secrets just like in Windows XP:

notepad rsyncd.conf        <== Same as Windows XP except that the path is now: path=/cygdrive/c/rsyncd/win7backup
notepad rsyncd.secrets    <== Same as Windows XP

Create rsyncd.cmd just like in Windows XP.

The file rsync.exe should be run with administrator privileges otherwise the backup process will fail. Using Windows Explorer, browse to c:\rsyncd and then right click on the file rsync.exe --> Properties --> Compatibility --> Run this program as an administrator.

Now run rsyncd.cmd and, just like Windows XP, a  popup message will appear. Just click on Allow and rsync.exe will run as a service.

Connect to your backup server and configure your new backup client. Do a full backup and if everything is working, then the last part is to create a shortcut to c:\rsyncd\rsyncd.cmd in the Startup folder so that everytime you turn on the computer, c:\rsyncd\rsyncd.cmd will automatically run.

rsyncd.cmd also needs to be run with administrator privileges. But in Windows 7, batch files (.cmd or .bat) can not be directly configured to Run as an administrator. But its shortcut can. So right click on the shortcut rsyncd.cmd --> Properties -- Shortcut --> Advanced --> Run as administrator.

Here is a picture of a Windows 7 Traditional Chinese (BIG5 charset) version client after a full backup:

Official documentation: http://backuppc.sourceforge.net/faq/BackupPC.html

Fr. Visminlu Vicente L. Chua, S.J.
2014/09/19