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.
 


-- 
Chris Devers

Reply via email to