SubVersion? is an increasingly popular substitute for CVS. One very useful application is to track changes to your local configuration files, which lets you:
- Keep a history of changes and why you made them.
- Revert problematic changes.
- Quickly configure new machines.
- Propigate changes to multiple hosts.
This document is mainly concerned with the first two features; the others can be easily implemented as variations of the same setup.
Also, the examples below are for a setup where the
SubVersion? repository resides on the machine being managed. If you want or need the repository on a separate host, then you'll need to configure a transport mechanism of some sort. Examples include an Apache and
WebDav? interface, and building a
SecureShell? tunnel. These are beyond the scope of this article.
Read through all of the steps before starting, as some necessarily involved manipulating critical system directories, and you need to assess the local impact of temporarily making certain files inaccessible before actually doing so.
Make your SubVersion? repository
- Install SubVersion?. If you have PortUpgrade, type
portinstall devel/subversion.
- Create a repository:
# svnadmin create /var/svn
Import your configuration files
Importing an entire directory into
SubVersion? is easy and well documented elsewhere. Instead, I'm more interested in tracking only the files that actually get modified locally. For example, on a normal
FreeBSD system, the wide majority of files in
/etc are copied straight from the master
FreeBSD CVS repository without any modification, so tracking those files is highly redundant. Furthermore, managing a few hundred generic files can bury your own interesting changes under a mountain of "diff"s. So, then, the following is a demonstration of how to put a certain directory under
VersionControl? without using
SubVersion?'s own
import command to slurp in the whole thing.
For our examples, assume:
- The hostname of the machine being managed is
cmhost.
- We're going to manage
/etc.
Now, the process:
- Create a
/hosts subdirectory and entries for the hosts you want to manage:
# svn -m "Making CM subdirectories" mkdir file:///var/svn/hosts
# svn -m "Making CM subdirectories" mkdir file:///var/svn/hosts/cmhost
# svn -m "Making CM subdirectories" mkdir file:///var/svn/hosts/cmhost/etc
# svn checkout file:///var/svn/hosts/chmost/etc .
That's all there is to it. Now you can use the full suite of
SubVersion? commands to add, rename, and annotate files.
Security Considerations
If certain files in /etc such as /etc/shadow and ssh keys are world readable, your system's security can be compromised. Do not put files that are not world readable in the repository unless the subversion repository is stored on the local computer and the directory containing the files can only be read by root.
--
KirkStrauser - 16 Feb 2004
--
TWikiGuest - 05 May 2004 (
ads@debian.org)
--
TWikiGuest - 16 Sep 2005