Dump/restore root ufs filesystem
Dump(8) The File Systems
The dump(8) utility literally dumps individual file systems. This is important – the standard FreeBSD configuration is to have the disk sliced into separate file systems – /, /tmp, /var, and /usr. We’ll need to dump all of them individually.
For our purposes, we’re going to dump into a file. Actually, we’re going to dump to stdout and pipe it to bzip2, and then redirect bzip2’s output to a file. Here’s an example of the command:
dump -0Lauf - /dev/nvd0p2 | bzip2 > /media/backup_root/2023-12-12-dump.gz
If you’re an experienced UNIX/BSD/Linux user, you can probably figure out what that does, but I’ll break it down anyway:
dump:
- 0: Dump level 0 – perform a full backup. Dump allows you to specify different levels to do incremental backups. The script below supports incremental backups because you pass the dump level on the command line.
- L: Tell dump that it’s dumping a live filesystem – this will cause dump to take a snapshot in time of the filesystem and then back up that snapshot. This is important as the contents could be in a state of flux while the dump is running.
- a: Auto-size the dump file. We’re not writing to a tape here.
- u: Update the contents of /etc/dumpdates. This file keeps track of the last time each file system was dumped, so it knows what to include in the incrementals..
- f: Write the backup to a file. In our case, we’ve specified “-” which means write the backup data to stdout.
- /dev/ad4s1f: The file system we’re backing up. On my system, this is /usr.
We then pipe (|) that output into the bzip2 utility, which would write the compressed data to stdout. Since we want that all in a file, we then redirect (>) the bzip2 output to a file, which will get uploaded to S3 by the backup script and duplicity.