Chris Devers wrote:
On Sat, 12 Mar 2005, Joel Rees wrote:


(One of these days I'm going to get version control running to my liking, and I'll keep everything under /etc in version control. For now, I just make a copy to work on and rename the old one *_nnn.bak or something, keeping track of the editing sequence in the _nnn portion.)


Try this:

    $ cat ~/bin/stamp
    #!/bin/bash
    #
    # stamp is a utility which makes a backup of a conf file

    [ $# -ne 1 ] && echo "usage: `basename $0` filename" && exit 100

    old="$1"
    new="$1.`date +%Y%m%d`.$$"

    [ ! -f $old ] && echo "$old does not exist" && exit 100

    cp $old $new

    status=$?

    [ -x $new ] && chmod -x $new

    exit $status
    $

It's crude, but it works well enough.

    $ cd /etc/httpd
    $ sudo stamp httpd.conf
      # I get a file like "httpd.conf.20050311.15629".
    $ vim httpd.conf && apachectl configtest
      # I make a royal mess of things. Damn.
    $ cp httpd.conf.20050311.15629 httpd.conf
    $ apachectl configtest
      # All is right with the world again.

Something like CVS / SVN / BitKeeper would be "better", but not easier.




Nice. You could also just op for RCS until you can get a more managed solution up, it works well enough for this type of thing and only (or not even) requires an RCS directory be created, and for you to follow the standard procedures,


> co -l filename
... make edits
> ci -u -M filename

Pretty simple stuff. It appears rcs comes with Mac OS X, or at least when the dev tools are installed.

> man rcs

For more info. The others are excellent, but they can be overkill for simple, non-distributed, configuration files.

http://danconia.org

Reply via email to