Previous Section  < Day Day Up >  Next Section

Recipe 18.5. Managing System Configuration Files with RCS

18.5.1 Problem

You want to preserve all versions of your system configuration files so that you can easily roll back to an earlier configuration, or just to preserve all of your brilliant configuration ideas as they occur.

18.5.2 Solution

It is tempting to stuff all of /etc into an RCS repository, but that's unnecessary and wasteful. Back up /etc in your usual manner, then use RCS to store only files that you change. Start out by checking the files you are going to edit into RCS. Check them out to make your changes, then check them back in when you're finished. Copy the working file to its final home in /etc after checkin. Then you will have a complete revision history of every configuration file that you edit.

18.5.3 Discussion

This example walks through creating an RCS repository for two programs, Amavisd-new and Clam Anti-Virus. Each program will have its own subdirectory in the repository. All commands are run as root.

# mkdir /rcs_configs

# cd /rcs_configs

# mkdir -p amavis/RCS

# mkdir -p clamav/RCS

# cd /amavis

# cp /etc/amavis/amavisd.conf amavisd.conf

# ci -l amavisd.conf

RCS/amavisd.conf,v  <--  amavisd.conf

enter description, terminated with single '.' or end of file:

NOTE: This is NOT the log message!

>> original amavis config, used with clamav and postfix

>> .

initial revision: 1.1

done

# co -l amavisd.conf

# vim amavisd.conf

Make your edits, save and close the file, then check it back in:

# ci -u amavisd.conf

Copy your working file into /etc:

# cp amavisd.conf /etc/amavis/amavisd.conf

and you're ready to go. Your original copy and first revision are safely preserved, and you're all set up to easily save additional revisions.

You may keep everything in single directory, rather than creating subdirectories for each program. It's up to you how to organize your files. Just remember to always change to the correct working directory before you start, or you'll find your files getting scattered all over.

When using RCS, it's easy to get confused and lock files at checkin instead of checkout, or to check out files and forget to check them back in. If you make such an error, the next time you try to check out the file, you'll get a message:

# co -l amavisd.conf

RCS/amavisd.conf,v  -->  amavisd.conf

co: RCS/amavisd.conf,v: multiple revisions locked by carla; please specify one

So when you specify a revision, you still get warnings:

# co -l -r1.4 amavisd.conf

RCS/amavisd.conf,v  -->  amavisd.conf

revision 1.4 (locked)

writable amavisd.conf exists; remove it? [ny](n): y

co: RCS/amavisd.conf,v: warning: You now have 2 locks.

done

The easiest way to get to get out of this is to open the RCS file (in this example, RCS/amavisd.conf,v) and edit it directly. You'll need to make it writable first:

# chmod 644 amavisd.conf,v

Then edit the header. Look for this:

head   1.4;

access;

symbols;

locks

       carla:1.1

       carla:1.2; strict;

comment   @# @;

Delete the locks, so it looks like this:

head   1.4;

access;

symbols;

locks; strict;

comment   @# @;

Save and close the file, and be sure to reset it to read-only:

# chmod 444 amavisd.conf,v

That's the end of the locks.

18.5.4 See Also

    Previous Section  < Day Day Up >  Next Section