I have following ZFS Snapshots:
data/server/dev1@snap1
data/server/dev1@snap2
data/server/dev1@snap3
If i want to rollback to snap1
, i would do the following:
zfs rollback data/server/dev1@snap1
but ZFS returns:
more recent snapshots or bookmarks exist
use '-r' to force deletion..
I know there is the possibility to simply copy the files out of /data/server/dev1/.zfs/snapshot/snap1
into /data/server/dev1
but that takes much longer than a zfs rollback
.
Is there a way to do the rollback AND keep the newer snapshots snap2
& snap3
?
Update 21/11/2016
It looks like there is a way to do this. I read about working with zfs promote
and zfs clone
but I could not figure out how it exactly works.
I think your comment is pretty close to getting you what you want. However, you could rename the file system before cloning then clone to the name of the original file system. For example:
zfs rename data/server/dev1 data/server/dev2
zfs clone data/server/dev2@snap1 data/server/dev1
You don't have to worry about promoting until you need to delete data/server/dev2@snap1
The zfs man page has a more complete example that may or may not address your needs more specifically:
The following commands illustrate how to test out changes to a file system, and then replace the original file system with the changed one, using clones, clone promotion, and renaming:
# zfs create pool/project/production
populate /pool/project/production with data
# zfs snapshot pool/project/production@today
# zfs clone pool/project/production@today pool/project/beta
make changes to /pool/project/beta and test them
# zfs promote pool/project/beta
# zfs rename pool/project/production pool/project/legacy
# zfs rename pool/project/beta pool/project/production
once the legacy version is no longer needed, it can be destroyed
# zfs destroy pool/project/legacy
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With