Updating BackupPC from series 3 to series 4

A lot of Linux distributions carried BackupPC v3 for a long time even when the 4-series had been stable for years. As a result systems that got installed before Debian 11 or Ubuntu server 22.04 were also using the older BackupPC variant.

BackupPC had a major overhaul of the backup storage format between versions 3 and 4, one of the big selling points being a lot better performance which was a very welcome thing for all of us who manage multi-terabyte installations.

BackupPC 4 is backwards compatible with the BackupPC 3 format and new backups are made with the improved version. However the existing backups won't be converted automatically. So if you were running Debian 10 or Ubuntu server 20.04 and upgraded to a current version, here's how to deal with BackupPC.

BackupPC processes and file ownership are for user "backuppc" in Debian and Ubuntu. You can not run any of the commands as root, switch to the backuppc user before running any of them. BackupPC daemon also can not run at the same time. The v4 format uses a lot more inodes than the older, so make you you either have enough free inodes with ext4 (df -i, see you're below 40% or so) or use a filesystem where preallocated inode count is not an issue (such as ZFS, btrfs and so forth). 

1. Preparations

If you're running BackupPC in a virtual machine and you have enough space to snapshot it, this might be a good spot to do so.

You may want to remove incremental backups from all hosts. I have come across several cases where full backups migrate just fine and incrementals cause the migration script to error out. YMMV.

Stop the BackupPC service:

systemctl stop backuppc

Switch to backuppc user. Since it does not have a password set by default, you have to go through the root user. 

2. Test with one host

Select one of the backup hosts as a test subject and make a dry run on it. In this example the -m switch causes the migration script to just print what it would do and -h specifies the host name. 

/usr/share/backuppc/bin/BackupPC_migrateV3toV4 -m -h example_host

This will list the backups and file counts for that host that exist in the v3 storage. If it looks good, migrate the host by omitting the -m switch.

/usr/share/backuppc/bin/BackupPC_migrateV3toV4 -h example_host

Since this will include copying files over, it will take from hours to days. Note that the first one will always be the slowest, as it will not need to copy files over if the file already exists in the new pool.

The outcome looks something like this:

BackupPC_migrateV3toV4: migrating host example_host backup #966 to V4 (approx 591362 files)
example_host #966: 0.0%
example_host #966: 0.3%
...
example_host #966: 99.6%
example_host #966: 99.8%
BackupPC_migrateV3toV4: converted backup in /var/lib/backuppc/pc/example_host/966; removing /var/lib/backuppc/pc/example_host/966.old

Once you're done with your test host and it looks good, it's time to convert the rest of them.

3. Migrate all hosts

Depending on your backup history, converting a huge system may easily take days. Take this in account as you won't be making new backups while the migration is running.

Migrating all hosts happens with the -a switch:

/usr/share/backuppc/bin/BackupPC_migrateV3toV4 -a

If you're accessing the system remotely, it's an extremely good idea to run this in a screen.

4. Cleaning up

After the migration start BackupPC daemon again:

systemctl start backuppc

Still using the backuppc user, force a full nighly maintenance, so it cleans up everything that was left in the old pool:

/usr/share/backuppc/bin/BackupPC_nightly 0 255

Once it's complete, go into the BackupPC web GUI, navigate to Edit Config -> Server and uncheck PoolV3Enabled. Save settings.

Navigate to Admin Options and click Reload.

The pool is now migrated.

No comments:

Post a Comment