While I’m a big fan of version control change tracking in general, I regularly find that the main version control systems don’t do quite what I, in the role of system administrator, want.
Sometimes all I want to do is copy any individual file or set of files to somewhere permanent, and make a note of why I made that copy (e.g. making a text configuration change or updating a CSS file). Whether the file is in /etc, /usr/local/bin/ or /var/log shouldn’t matter, and whether it’s text or binary again shouldn’t make a difference.
I’ve asked and looked around, and the closest thing would be a backup script, but obviously they are more likely to mark a backup by time and date, not a reason for the backup, plus they need on-going management and installation on any server you’re using.
To come up with a solution, I’ve written a quick and simple Bash shell script (which should work on AIX, Solaris, etc, with Bash installed), which:
- Asks for the reason for the copy
- Copies all files specifed on the command line to /var/echange/ with a time and date appended to the name
- Creates a text file named after the new copy of the file with .echange added which contains the original name and location of the file, and the reason for the change.
To make a copy I just run
ec index.html test.css
And I’ll be asked for my reason, simply end the input by pressing return, and the files will be copied.
If I want to find an old copy of the file, this way I can just run
find /var/echange -name “originalfilename.*”
and find all versions of the original file that I’ve copied, and the reason why I made the copy.
I don’t know if anyone else will find this of use, but since I want it to be available for me on various systems, I’ve uploaded the file to http://www.ewanleith.com/files/ec.txt – Simply download the file to your Linux server, copy it to /usr/local/bin/ec and mark it as executable, then create /var/echange and you’re good to go.
It can also work with any other directory than /var/echange/, simple change the line at the top of the bash script to wherever you want.