We'll start with a simple type of short term backup.
Here's a typical use-case: you're starting to make some serious changes to a
critical file (maybe a presentation, maybe some system configuration file like
sendmail.mc, or whatever). Before you start, you do what almost everyone
does: make a backup called sendmail.mc.orig or sendmail.mc.bkp.
This is simply due to the human fear of messing up something so bad you want the ability to start over again from a clean slate.
We all do it. And pretty soon our directories are cluttered with all these horrible files!
What's unique about these "backups" is that they're usually not needed after the changes are successfully done -- they're only for emergencies. As a result, even CVS or RCS is too much clutter and cleanup.
In fact, I hesitate to even call it backup -- it's really more in the realm of version control.
We use plain old tar!
Everyone knows the basics of tar (cvf to create a tar file, tvf to
list the contents of a tar file, xvf to extract it, z or j options
for compression, etc.)
But tar has another mode, called "update" mode, which appends to the
archive all the files listed on the command line as long as the archive does
not already have the latest version. If no files listed have changed, nothing
happens.
And yes -- this means that a tar archive can save multiple revisions of the same exact file!
tar uvf ~/rescue.tar files-to-save is what I use. The tar file into
which I save is always ~/rescue.tar; avoids clutter in local
directories too!
tar xvf ~/rescue.tar file-you-want
What happens is that each copy of the file gets restored to the same filename on disk, in the order they are present in the tar file, so the latest version is what finally ends up on disk. A little wasteful, but that's OK.
tar tvf ~/rescue.tar file-you-want | nl
Now look at the timestamps to figure out whether the one you want is the first one, the second one or whatever. Let's say you want the 7th one (the nl command numbers the lines for you!) Once you know that, all you need is
tar xvf ~/rescue.tar --occurrence=7 file-you-want
Note: the timestamps reflect when the file was last changed, not when the file was backed up! In a typical session, if I have to recover, the one I really want is probably dated at least a day ago, assuming I started today's work with a quick backup.
Please remember this is not a long term backup solution! As such, it is only useful when
Well, the next chapter: Creating a mirror, local or remote, efficiently