ZFS – How to Remove Files from Snapshots

zfs

Say I have a dataset with 100 snapshots and want to rm -rf all folders named "cache" in all snapshots.

I want to actually free up the space, not just hide it away in layers of snapshots, so making a clone and removing from that and then taking a new snapshot doesn't seem to do what I want.

Any semi-automatical way do that?
Some wrapping around zfs list -t snapshot, zfs clone, zfs promote, zfs snapshot?

(cross-posting from https://superuser.com/questions/313197 since I see this has more ZFS stuff)

Best Answer

Snapshots are read-only. If you need those folders gone then you have to delete the whole snapshot.

You can make a backup (with something like tar), excluding the offending folders, then delete the snapshot. Obviously the backup is now in tar, or whatever, format; but at least you still have a backup copy.

Related Topic