I like duply, but unfortunately there is not much in the documentation about best practices or howtos. So here is the first post in my duply series: how to back up the root file system.
The obvious approach is to set SOURCE=/ in the duply conf file and we are done. The problem is there are lots of other filesystems mounted under root, like /sys, /proc, /dev, /run, etc. So we could come up with a long list of excludes and try it that way and this setup would still be wrong and fragile.
The correct way to do this is to bind mount the root filesystem somewhere else, and back up that mountpoint. This way we shall get the root, the whole root and nothing but the root. So create a pre script like this:
# This script shouldn't have chmod +x because in older duply version we don't have access to variables like $SOURCE set -o pipefail set -o nounset set -o errexit # Bind mount: if ! mountpoint -q "$SOURCE"; then mount "$REAL_SOURCE" "$SOURCE" -o bind mountpoint "$SOURCE" || exit $? fiNow add a new variable into the duply conf file and change the SOURCE variable to the bind mountpoint. I like to use /mnt/root-bind:
# The duply pre script will bind mount $REAL_SOURCE under $SOURCE REAL_SOURCE="/" SOURCE="/mnt/root-bind"One more thing to take care of is now we will have to make sure duply doesn't start the backup in case the pre script fails. So instead of starting the backup with
duply $profile backupwe'll have to do it like this:
duply $profile pre_and_bkpThat's it, enjoy your root filesystem backups.
Coming up next: how to run duply from cron, how to encrypt and sign your backups, how to backup btrfs, lvm, mysql and svn repos.
No comments:
Post a Comment