RetroBSD Net
Title:
built-in snapshot support in fsck and dump
Authors:
Paolo Vincenzo Olivo
Date:
Topics:
NetBSD
Id:
4wymk2

A question on UniteBSD moved me to add something to my previous post with regard to ffs snapshots and backups. It is probably worth mentioning how fsck_ffs(8) and dump(8) can directly make use of snapshot with the built-in `-x` option, which automatizes the process of ffsX (un)configuration.

■ fsck_ffs -x [snap-backup]

The -x options of fsck_ffs(8) can be used in conjunction with -n to check data integrity on a filesystem mounted rw, by comparing the filesystem against an internally consistent atomic view of itself. The -x option creates a FFS snapshot using a temporary backup log at the specified path to write potential changes to the filesystem. If the check fails, the filesystem should be unmounted and fixed.

~ $ fsck_ffs -x /var/snap -n / ** /dev/rfss0 (NO WRITE) ** File system is journaled; replaying journal ** Last Mounted on /altroot/ ** Phase 1 - Check Blocks and Sizes ** Phase 2 - Check Pathnames ** Phase 3 - Check Connectivity ** Phase 4 - Check Reference Counts ** Phase 5 - Check Cyl groups 6472 files, 322806 used, 4760097 free (2921 frags, 594647 blocks, 0.1% fragmentation)

■ dump -x [snap-backup]

~ $ dump -0ua -f cgd.dump -x /var/snap /etc/cgd DUMP: Found /dev/rdk0 on /etc/cgd in /etc/fstab DUMP: Date of this level 0 dump: Sat Mar 19 10:00:50 2022 DUMP: Date of last level 0 dump: the epoch DUMP: Dumping a snapshot of /dev/rdk0 (/etc/cgd) to cgd.dump DUMP: Label: none DUMP: mapping (Pass I) [regular files] DUMP: mapping (Pass II) [directories] DUMP: estimated 52497 tape blocks. DUMP: Volume 1 started at: Sat Mar 19 10:00:50 2022 DUMP: dumping (Pass III) [directories] DUMP: dumping (Pass IV) [regular files] DUMP: 52493 tape blocks on 1 volume DUMP: Volume 1 completed at: Sat Mar 19 10:00:52 2022 DUMP: Volume 1 took 0:00:02 DUMP: Volume 1 transfer rate: 26246 KB/s DUMP: Date of this level 0 dump: Sat Mar 19 10:00:50 2022 DUMP: Date this dump completed: Sat Mar 19 10:00:52 2022 DUMP: Average transfer rate: 26246 KB/s DUMP: level 0 dump on Sat Mar 19 10:00:50 2022 DUMP: Closing cgd.dump DUMP: DUMP IS DONE

Looking at the stdout about, pay attention to:

DUMP: Dumping a snapshot of /dev/rdk0 (/etc/cgd) to cgd.dump

This eliminates the main problems of using dump to make a full system backup without a snapshot mounted, which is dumping the ongoing dump itself, and possibly screw up both the filesystem and the backup if anything goes wrong. By using -x, I can therefore directly dump /, because under the hood dump will be making a FFS snapshot before dumping the filesystem and mirroring the snapshot, rather than the filesystem itself. I hadn't mentioned this in the post, since the man page says it's experimental. On second thought, it would have been better to include that too. Searching the mailing lists, I found a couple of ancient posts with people reporting using dump -x reliably to carry out backups in the log run. But I haven't experimented myself, and I didn't want to risk, so I preferred the 'manual' approach.


Powered by NetBSD