LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Periodic LVM snapshots (https://www.linuxquestions.org/questions/linux-server-73/periodic-lvm-snapshots-846763/)

hydraMax 11-26-2010 03:47 PM

Periodic LVM snapshots
 
I want to start making snapshots of my system LV once every two weeks, so that I can roll back quickly if I mess up my system configuration somehow. I can make a snapshot by following the instructions in the manual pages, but I am unclear on one point: do I have to create a new snapshot each time (i.e., after deleting the old one) or is there some command to make a existing snapshot "forget" its original state and start tracking changes again from a fresh point?

acid_kewpie 11-27-2010 11:57 AM

Well with the way that a snapshot works I would suggest that it's not like that in the first place. You have a fixed amount of space assigned to the snapshots, say 20% of the partiton. So once the live state has been changed to the extent of having to use the spare 20% of the disk space, there is no longer any space to keep the old snapshot in one piece, and as such it is invalid. If you make 2 snapshots, one after half that 20% has been used up, then the first 10% is only relevant to the first snapshot, then 2nd 10% that makes up the first snapshots 20% is also common to the 2nd snapshot. There is no cost to making as many snapshots as you wish, and it's not like you could create a snapshot, create a large file, delete that file and then have LVM magically know that the two filesystems (live and snapshot) are actually identical, it doesn't (afaik) track anything intelligently like that at all, no undo's etc, so the changes are completely linear - thus 10 snapshots still use up the "same amount of resources" as the very oldest one in that list.

Or at least, that's the way *I* understand it. If you understand me...

And so for your question, it doesn't matter about the old one either way. Delete it proactively if you wish, but it won't have any implications for any other snapshots.

syg00 11-27-2010 03:57 PM

I haven't had my first cup of coffee yet, so you lost me there Chris... :p

I recently tested btrfs snapshot on Fedora - taking auto snapshots on yum updates (think "emerge world"). Nice idea similar to what the OP is thinking of. Snapshots are a "point in time" copy. End of discussion.
They are "lightweight" (supposedly) because they are a cow (copy-on-write) implementation. Problem I found was that because I took them just before each update, the snap effectively became the size of the update. I hadn't bothered to implement a deletion regime (because they are "lightweight" remember - d'oh) and quickly burned 20 Gig of my root partition. That resulted in a full filesystem till I figured out what had happened.

Short answer - delete the old(est) snaps, and enjoy the convenience - same concepts apply to both LVM and btrfs for this AFAIK.

acid_kewpie 11-27-2010 04:11 PM

so comparing that with lvm, the about is in reserved space in the partition, which is fixed, so you can never gave them cause you to run out of space, they just become invalid if the size if the changed data is larger then the reserved snapshot space.

acid_kewpie 11-27-2010 04:14 PM

I'd also say that a word as benign as 'copy' can be very misleading. The data isn't actually copied per se, so wouldn't take up double the space etc.


All times are GMT -5. The time now is 06:27 AM.