With kernel 2.6.30 there's a shiny new filesystem officially available. NILFS2 provides
- checkpoints at regular intervals (unless there is no change) or with synchronous writings
essentially that means that everytime you write a new file you will have a new version of your filesystem just ready to be mounted at a convenient place so that you are able to restore the version of the file from just about 2 seconds ago. Check the details of NILFS on the wikipedia page for a good overview. This post will be about basic usage and some ideas I have how to put it to actual use in a production environment.
So getting nilfs running on Debian/Squeeze (in that case as I tried it on my workstation) isn't much of a problem. A couple of commands and you are good to go:
Now with this you can start using your shiny new nilfs2 2 partition right away, the interesting part comes from the snapshots you are able to use with nilfs2. Use lscp to show how many checkpoints have been created.
Yes I did this from a random directory, lscp will try to find a nilfs2 filesystem by looking at /proc/mounts. Regarding the meaning of the columns I’m pretty sure you can read the manpage yourself. Now let’s get a mount from an older version of the filesystem. This involves 3 steps:</p>
- find the checkpoint you want to mount
- make the checkpoint a snapshot
- mount it
Aha! Now we have a version from just a couple of minutes before we did something to our filesystem.</p>
How do we put that to actual use now?
- Continuous Data Protection - imagine you have some kind of interface where users can mount arbitrary snapshots to restore a file they just destroyed. Forget about those high budget data protection tools
- Poor (Wo)Mans Version Control - I do know quite a couple of developers who don't check in to their soruce repo often enough. Could be some help for them
- Nicer Backups - quite a couple of server don't have any option without being taken down. Linux LVM snapshots take quite a while to finish, with NILFS2 this takes nearly no time.
- shutdown # this is probably the part that takes the longest
- startup again
- take care of the backup
Of course those are just very vague ideas but I hope a richt environment of nice tools will build around it. Of course I'd wish that btrfs would have that feature (or the other way around) because I like the idea of the volume manager being built into the file system. I can't yet exactly say why but to me it just seems to be the right place for it.Server!/Horror