How does deleting the oldest ZFS snapshot not break the flow of data?
I'm not new to ZFS. I've been using it a couple of years but I've only just started making snapshots and I've created a cronjob and script to take a daily snapshot of a few of my datasets, which all reside under the same pool.
I was looking for a quick way to list my snapshots in another cron script so that I could destroy the oldest one. The goal is to have a continuously rolling set of 7 snapshots: so I can roll back to any day out of the last 7 days.
I have my script running and I currently only have 1 set of snapshots (today). I found a very cool answer, here by https://serverfault.com/users/15810/AaronLS for finding the oldest snapshot and destroying it. I plan to add this into my bash script, so that it takes a snapshot each day and immediately afterwards it finds the oldest one and destroys it.
The answer by AaronLS is in this question: How to delete all but last [n] ZFS snapshots?
My question is one of ignorance, really. I thought that the first snapshot you made from any given dataset was a complete image of that dataset, with any further snapshots being based on that first snapshot and any more recent snapshots were merely a record of the changes since the first snapshot.
So if I delete the very oldest snapshot, does ZFS then have to alter the second-oldest snapshot in order to have a complete "first snapshot" image again?
Have I explained myself correctly? Surely if you delete the original snapshot then the next oldest now becomes the "orginal" snapshot and would need some data juggling around in it, in order to become a full dataset image?
Could someone explain it to me in laymans terms why my assumptions are wrong? I feel that I kind of understand snapshots but I'm just lacking confidence. I was going to try running my script tonight, on a 10 minute crontab, so that I could simulate a week's worth of snapshots in 70 minutes but I'm not confident that I understand the maths before I go ahead.
I apologize for the bad formatting, too. If I knew how to quote a username and link to another article properly I will edit this post to make it neater. I've not posted on here for a long while.
Thanks.
If I'm not mistaken, when you take a snapshot, nothing happens, it's just a timestamp. Then your data starts changing. Before every change, the original data is copied to the snapshot.
Each snapshot is a compete index of the data required to represent the file system at a point in time. Apart from the shared data space, the snapshots are totally independent of each other.
You are thinking in terms of deltas, but zfs snapshots are not deltas. They don't contain any of the actual data so there's no benefit in doing it that way.