I am doing some changes to my data and forgot to explicitly take a snapshot before doing these changes. I use sanoid, so there are plenty of snapshots from before I started making these changes. I was wondering if there is a good way to copy one of these snapshots to a new snapshot so it won’t be eventually cleaned up by sanoid and will have a distinct name to make it easier to find if I need it in the future?
I like the idea of creating a copy of this snapshot, but maybe I am overthinking this. If I rename the snapshot from before I made the changes will this prevent the sanoid pruning script from deleting it (as well as using a zfs hold for good measure)?
Thanks!
This isn’t an issue; sanoid will not remove a snapshot with dependencies on it. You can just clone it, work with it until you’re done with it, then destroy the clone. Once the clone has been removed, sanoid will be able to prune the snapshot on its next run.
zfs clone pool/ds@snapname pool/tmp and you’re ready to start getting stuff out of /pool/tmp.
Other than that, you can’t really “copy” the snapshot–short of a full replication (which means every single block linked in the snapshot gets copied and begins taking up space). Probably not what you want.
But if you really want to be able to find which snapshot you based the clone on later, you can rename it:
zfs rename pool/ds@snapshot pool/ds@parent-of-the-clone
… or whatever.