ZFS: Removing files from snapshots?

Solution 1:

You could try the following:

  1. Clone the oldest snapshot into a new filesystem (call it fsnew).
  2. Promote the clone (fsnew) to allow you to destroy the snapshot the filesystem is based on.
  3. Remove the offending files.
  4. Create a snapshot of fsnew.

Now foreach snapshot after, rsync with the --inplace flag from the snapshot to fsnew skipping over files you do not want. The --inplace flag reduces the number of writes and allows for smaller snapshots.

  1. Create a snapshot of fsnew.
  2. Destroy the original snapshot.

When this is done, you should have a snapshot on fsnew that corresponds to the snapshots from the original filesystem with the offending files removed.

If you have the space on the drive, you may want to skip the "destroy" command until you have got your script working right.

Solution 2:

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.

Tags:

Zfs