Backing up and restoring from XFS volumes
You’ve moved to XFS volumes and low-and-behold your super simple yet extremely important backup process stopped working. Dig a little and you learn that XFS volumes require their own tooling to do backups at the block level so the old “dump/restore” packages you relied on won’t work.
That is what happened to me.
I do monthly full backups of my personal systems and daily incrementals. On top of that, I do them from a central system and back the other systems up via SSH. It is not a big environment, so this is an easy to maintain system which does disk-to-disk backups complete with compression. It is optimized, quick, and very portable.
I had to tweak my backup tooling ever so slightly to make it use xfsdump with the right flags. It was a bit of a pain to do, but not terrible.
My backup line looks like:
/usr/bin/ssh host_to_backup "/sbin/xfsdump -l5 - / | /usr/bin/ssh backup_server /usr/bin/dd of=/backup/month.0/daily.0/host_volume.dgz"
The script does a lot more than that. It will rotate through all of the volumes on the host to be backed up and name the file accordingly, switch between full and incremental backups based upon the date (first sunday of the month, for example), and it creates and maintains a defined (at runtime) number of “month” folders and daily folders. I try to keep it simple considering at the time of a restore you are usually under pressure. The last thing you want to do is scramble to search through a bunch of files and folders. So the naming convention makes it easy: month.0 is the current month, month.1 is last month, and so on, and daily.0 is today, daily.1 is yesterday, and so on. On top of that, the files have their date stamps, so if you are looking for a specific date (the 17th) it is quick to locate.
Now, to restore, I like interactive restores. I find the vast majority of the time, it’s a surgical restore: restore a file or folder.
xfsrestore -i -f /backup/month.0/daily.0/host_volume.dgz .
It is important to remember xfsdump and xfsrestore are sensitive with the ordering of the command line options. For example, xfsrestore did not like combining -i and -f into -if so do not make that assumption.