Configure the BackupPC server for on-demand laptop backups
- Configure BackupPC if you have not already done so. Here are the instructions to configure it using settings I find appropriate. These steps must usually be done as root and/or the BackupPC CgiAdminUser.
- Add at least one CgiAdminUser in /etc/BackupPC/config.pl and restart the server to activate it.
# /etc/init.d/backuppc restart
- Download my predump and postdump scripts. I store these in /srv/on-demand/scripts, but they can be stored most anywhere as long as the backuppc user can read and execute them and you use the correct paths to them below.
# mkdir -p /srv/on-demand/scripts
# cp /path/to/predump /srv/on-demand/scripts/
# cp /path/to/postdump /srv/on-demand/scripts/
# chown backup:root /srv/on-demand/scripts/*
# chmod 500 /srv/on-demand/scripts/*
- Log into your BackupPC server as the admin user and make as many of the following changes as you like. I've tried to indicate with bold the settings I believe are mandatory.
- Xfer/XferMethod: rsync
- Server/WakeUpSchedule: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23
- Server/MaxBackups: 4
- Backup Settings/ClientNameAlias: <blank>
- Backup Settings/PingCmd: /bin/ls /srv/on-demand/cache/$host/status/readyforarchive
Adjust path as necessary. This can be a per-client setting if your BackupPC server handles desktops and/or servers too.
- Backup Settings/PingMaxMsec: 0
- Backup Settings/DumpPreuserCmd: /srv/on-demand/scripts/predump $host
Adjust path as necessary. This can be a per-client setting if your BackupPC server handles desktops and/or servers too.
- Backup Settings/DumpPostUserCmd: /srv/on-demand/scripts/postdump $host
Adjust path as necessary. This can be a per-client setting if your BackupPC server handles desktops and/or servers too.
- Backup Settings/UserCmdCheckStatus: CHECKED
- Schedule/IncrPeriod: 0.04
Adjust to just less than wakeup interval you use.
- Xfer/RsyncShareName: /srv/on-demand/cache/REPLACEME/c
"REPLACEME" above is a placeholder and a reminder that this setting must be adjusted for each on-demand client.
- Xfer/RsyncClientCmd: /usr/bin/sudo $rsyncPath $argList+
This can be a per-client setting if your BackupPC server handles desktops and/or servers too.
- Xfer/RsyncRestoreCmd: /usr/bin/sudo $rsyncPath $argList+
- Xfer/RsyncRestoreArgs: <delete all>
This is for security; otherwise any user can perform direct restores to ANY directory on the BackupPC server!
This can be a per-client setting if your BackupPC server handles desktops and/or servers too.
To disable direct restore, this setting's value to be "undef" in config.pl. Due to a bug in BackupPC 3.0.0, this must be set to undef by direct editing of config.pl. Warning: editing the setup via the CGI after changing this will change the value from undef back to [] unless you apply the patch located at http://sourceforge.net/mailarchive/forum.php?thread_name=Pine.LNX.4.64.0710101119300.32233%40hellbender.physics.unc.edu&forum_name=backuppc-devel.
The settings in bold above are easier to make globally, but can be set in the client configs.
- Allow the backuppc user (probably backup or backuppc) to sudo rsync without a password. I do this by adding the following line to /etc/sudoers:
backuppc ALL=NOPASSWD:/usr/bin/rsync
- Add the user that runs the backuppc processes (probably backup or backuppc) to the laptop group in /etc/group. This is necessary so that the backuppc user can manipulate the flags in the laptop-users' "status" directories. (Alternatively, you can allow the backuppc user sudo permission to perform /bin/touch and /bin/rm, but this is less secure.)
- Add an on-demand client to BackupPC. If you did not configure the settings in bold above globally, set them for each on-demand client.
- Be certain to change Xfer/RsyncShareName in the client's config by replacing REPLACEME with the laptop-user's username.
- Restart backuppc by reloading the settings via the CGI or restarting the backuppc process on the server.
NOTE: If you install BackupPC so that its data directory is not /srv/on-demand/archive you will need to adjust the paths in the predump and postdump scripts as well as use your location when configuring clients' RsyncShareNames.