Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I would like to know if there is any existing unix utility or tool that would make a backup of a file with a date/timestamp appended to the filename.

Basically I am looking to automatically make backup of my config files like the .bashrc, .vimrc, etc when I change the file and save using some text editor.

vim specific solution would also be helpful. May be adding some kind of hook only for specific files that creates a copy of the previously saved file and then goes on to save the currently modified file.

share|improve this question
    
Closest I can think of would be incron or something similar. It won't back up before the change but you can use it to backup after a change (but this becomes a lot of a finer/moot point after you get one or two revisions into things) and you can use tmpwatch to clean out old revisions after a certain amount of time. –  Bratchley Jun 4 '13 at 10:53
    
I'm not aware of any such tool, but then again I haven't looked. However, you say Unix. Which Unix are you talking about? I imagine that something like this would be pretty system-specific, so it might help specifying the environment more precisely. –  Michael Kjörling Jun 4 '13 at 10:59

2 Answers 2

I'm using a simple backup scheme that appends a .YYYYMMDD[a-z] extension, too.

For that, I've written a set of Vim plugins and scripts: The writebackup plugin defines a :W[riteBackup] command in Vim that makes a backup of the current file.

With the writebackupAutomator plugin, you can have Vim make the backup automatically.

And the writebackupVersionControl plugin offers you additional commands from "real" version control systems, like diffing and moving through history.

In addition to the Vim plugins, I also provide the basic writebackup functionality outside of Vim as VBScript and Bash Shell script versions on my personal website; maybe those are helpful to you or at least provide a starting point!

share|improve this answer

You can configure Vim to make backups automatically in various ways. For example, I think you could hook into the writebackup plugin for certain file groups.

The CopyFS filesystem keeps copies of all old versions of the files stored on it.

But I don't recommend either of these approaches. The best way to keep backups of old file versions — which is a good thing — is to keep them under version control. A simple version control system such as CVS takes about ½ hour to set up. A more modern and more powerful, but more complex system such as Bazaar or Git or Mercurial might take a whole hour. Spend an afternoon setting them up and learning the basic commands, you won't regret it.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.