BackupPC pre-loading / seeding and migrating / moving script

This script can save (restore to tar), seed (pre-load) and move (migrate, switching between old and new backuppc partitions on the same server) BackupPC backups.

The latest version of the script is found here:
https://owncloud.molnix.com/index.php/s/t879KKwnHg7nHDu

Updated 2016-09-03: Now able to use a buffer to further improve save speeds. This is especially useful when the backup contains a mix both large and small files, which is typical for user data folders and application files.

Updated 2016-10-04: Now improved buffer functions with progress information using either pv or mbuffer.

Updated 2016-10-05: Added option to use pigz for further save speed improvements.

It works at least for tar and rsync transfer modes and with BackupPC 3.3X. For migration, it is considerably faster and more portable than migrating the pool, but previous backups will not be included. Migrating to another server is done using save on the old and seed on the new.

Some use cases I can think of for this script are:
– Pre-loading secondary servers at another location
– Moving to another partition when hardlink preservation takes too long
– Taking the usable parts of a corrupt pool when starting a fresh one
– Making a last state dump for archival before removing a host from BackupPC
– Transitioning from BackupPC 3 to BackupPC 4

Note that seeds will be saved as partial, as the dump ends with: “Got fatal error during xfer (No files dumped for share /)” This is likely due to unexpected output from zcat (missing –total?). This is actually good, since it ensures a full backup will be run with the real host afterwards, so I did not look into it further.

Before starting a seed or move (saves can be done any time):
– Make a backup of your config.pl file, restore it afterwards
– Set MaxBackups to 0 and make sure no backups are running
– Set XferMethod to ‘tar’
– Set TarClientCmd to ‘zcat /tmp/bpctar/target’ (as set in FILEAREA below)
– Set TarFullArgs to be empty
– Set PingCmd to ping -c 1 localhost if hosts are not reachable as usual
– If moving, set up your installation so that the config points at a link   to the actual storage area
– If moving to a fresh directory, prepare it as needed, for example:
cd /mnt
sudo mkdir -p backuppc/cpool backuppc/log backuppc/pc backuppc/pool backuppc/trash
sudo chmod -R 750 backuppc
sudo chown -R backuppc:backuppc backuppc
cp -a /srv/backuppc/.ssh/ /mnt/backuppc/