Managing and securing data on OpenBSD: maintaining filesystems with fsck, using dump and restore for filesystem-level backups, taking consistent FFS snapshots, and combining tar, cpio, and rsync in a battle-tested base system backup strategy.

In episode 10 you secured services with TLS and automatic certificates. But all that configuration, those certificates, and that data are only worth something if they can be restored. This episode covers the side administrators often forget: data management and backup.
The OpenBSD philosophy applies here too: use proven built-in tools, understand what you're doing, and never trust a backup that hasn't been restore-tested. Backup isn't an "if you have time" activity — it's insurance whose price becomes visible precisely when data is lost.
Episode 7 introduced fsck for filesystem checking. In the context of data management, fsck is the first step before backing up: don't back up a damaged filesystem. The correct pattern:
umount /dev/sd0d
fsck -y /dev/sd0d
mount /dev/sd0dAlso check usage and inodes so there are no surprises during backup:
df -h
df -idf -i shows inode usage. Running out of inodes can happen without the disk being full — a condition that makes applications behave strangely.
dump backs up a filesystem at a supported level (0 = full, 1-9 = incremental). Its advantages: it works on the raw device, preserves metadata, and supports incremental backups:
dump -0au -f /backup/root.dump /dev/sd0a
dump -1au -f /backup/root.inc.dump /dev/sd0a-0 level 0 (full), -1 the first incremental level.-a detects media capacity, -u records history in /etc/dumpdates.Recovery is done with restore:
restore -rf /backup/root.dump
restore -tf /backup/root.dump-r performs a full restore, -t lists the contents without extracting. Always check the contents list first.
Warning
dump must be run on an unmounted filesystem or on a snapshot (see the next section) so the result is consistent. Mixing data that changes during the dump process can produce an untrustworthy backup.
FFS2 supports snapshots: a consistent image of a filesystem without stopping services. Take a snapshot then dump from it:
mount -u -o snapshot=/var/snap/root.snap /dev/sd0a
dump -0af /backup/root.snap.dump /var/snap/root.snap
mount -u -o snapshot= /dev/sd0aThe snapshot is mounted as a file in the /var/snap directory, then dumped like a regular filesystem, then released. This is the correct pattern for production servers that can't stop.
For backing up specific directories (not a whole filesystem), tar and cpio are the choices:
tar -czf /backup/etc.tgz -C / /etc
tar -tzf /backup/etc.tgz | headcpio is useful when the file list is produced by another command:
find /var/www -type f | cpio -o > /backup/www.cpioNote that tar and cpio work at the file level, not the filesystem level — fast and flexible, but they must be run on a live system or from read-only mounted media to be consistent.
rsync is the most popular third-party package for synchronization. Install it first:
pkg_add rsyncThen synchronize a directory to a backup server:
rsync -aAXv /var/www/ backup:/backup/www/
rsync -avz --delete /var/www/ backup:/backup/www/The -a (archive), -X (preserve xattrs), -z (compression), and --delete options make rsync mirror the source to the destination. For rsync over SSH, add -e ssh — taking advantage of the SSH you'll harden in episode 14.
The OpenBSD base system rarely changes except during upgrades, but its configuration files absolutely must be backed up. The minimum list that should always be in a backup:
tar -czf /backup/base-config.tgz /etc /root /var/cron
ls -la /backupAlso consider recording the package list so you can reinstall quickly:
pkg_info -Q | awk '{print $1}' > /backup/packages.txtThis packages.txt file is a "manifest" that enables fast recovery: install clean OpenBSD, run pkg_add $(cat packages.txt), and your system is back.
Danger
A backup that has never been restore-tested is not a backup — it's just hope. Do regular restore tests in a separate environment, at least every time the backup strategy changes. Episode 18 (virtualization) provides a safe place to test these restores.
A sensible combination for a production server:
/etc/weekly.local.All of these schedules can be run by OpenBSD's built-in cron without extra tools.
In episode 11 you managed and secured OpenBSD data: maintaining filesystems with fsck before backup, using dump/restore with FFS snapshots for consistency, archiving with tar and cpio, synchronizing with rsync, and arranging a restorable base system backup strategy.
Key takeaways:
fsck first.dump works at the filesystem level, tar/cpio at the file level, rsync for synchronization.In the next episode, episode 12, we enter the heart of OpenBSD's network security: pf firewall fundamentals — understanding /etc/pf.conf, the ruleset concept, block and pass, service rules, logging via pflog, and the habit of validating with pfctl.