Introducing new CLI feature for snapshotting huge directories

Can you imagine doing a backup of a huge directory in only 1 second? and the best, to not use the hard disk writes so you won't deteriorate it...

Story: I was going to do some tests in the enlightenment repository that uses 2 GB with compilations inside, so I was going to run "bkp save" to do a backup of it, so that after my changes, if unsuccessful, i can easily recover its previous state, or compare it with "bkp diff / bkp meld", but then I realized that backuping / recovering 2 GB all the time is not the optimal, especially now that I'm being (even more) obsessed with speed...

That's how bkp snap was born... see it in action! :happy:


mentions: @PrinceAMD @TheTechRobo @triantares


Looks awesome to me.
I must say I'm having trouble in wrapping my head around how copy_on_write actually works. :thinking:
I'll get there eventually. :innocent:

Copy-on-write is where you don't actually copy anything until it's changed. So you can make a copy of a directory (like here), and not much will happen, but when you change/delete/rename a file, it keeps a copy of the old data around. That way you can easily revert your changes.
I am interested in what happens if you open a second terminal in that directory, though, because it looks like the CoW is only set up for the shell you are in.

1 Like

That sounds like a good feature to have, how do I get the latest version of bkp ??? Am on Elive 3.8.40

same thing (changes will happen the same way), but the control is on the actual terminal (you need to exit the active one to ask if you want to recover it + deletion of snapshot)

btw the snapshot is in the same parent dir + .snapshot appended in the name

just run "apug" to update all your system :slight_smile:

1 Like

Yes, I gathered that but I'm wondering whether CoW is keeping all changes in RAM until final completion or that it compares to a 'zero' position i.e it has to have something like a database to compare to.

Keeping in RAM is risky in case of crashes and such and and in the latter, first creating a snapshot of the 'zero' situation would be time consuming.
The only 'light' way I can imagine is using timestamps. :confusing:

Update: "snap" will now do updated snapshots if run again, this means that everytime you do "bkp snap", the snapshot will be a fresh one removing the previous one, more like "I like this state, let's make a backup again of this new state"

@triantares not managed in ram, is a filesystem feature, think on it as a bunch of "hard links" in the filesystem, so they will have the same contents, but if you modify a file/directory in one of the A / B places then the hardlink of that file will turn into a normal file which can have a different state / contents between A / B places, and everything else still a hardlink