Categories

Albums

Shots

Pictures of things possibly worth looking at.
12 June 2012
1 images in album
2012_06_13/P6123751.jpg

Emblems

Powered By Jaws Project
Powered By Apache HTTP Server
Powered By MySQL
Supports RSS
Powered By RSS Lounge
















Tracking Changes to Important Files with Subversion

aka. Revision Control for /home and /etc folders

Introduction


In Unix, the /etc folder contains most if not all of the system's configuration files. /home usually contains folders for all the system's users. I once read an article from a self-admitted obsessive-compulsive sysadmin who kept his home folder under revision control using a program called subversion. I thought this was a nifty idea, but of course, I didn't quite find the article to be a one-stop how-to on the subject. I'll spare you the long story of everything I did to get this working; here's what I did right:

Getting Set Up


I set up my new computer and installed the base operating system. Don't be jealous... it's an old, second-hand laptop which is now running Gentoo Linux. Subversion was one of the first pieces of software I installed once the system was up and running. I decided that, at least for now, I don't need to set up a fancy daemon to act as a subversion server, so I just created the repository as root with the plan to check-in all my changes using the file:/// protocol to access the repository, since I'll always be committing the changes locally. Logged into my machine as the root user, I got down to it:
mkdir /var/svn/repos
svnadmin create /var/svn/repos/backups

Dealing with Special Files


I quickly realized that file ownership, permissions, and special files such as devices would be an issue, so I downloaded a little script called asvn which is a wrapper script to subversion, to keep track of these properties that don't normally get recorded in a repository. I had to edit the script, which I put in /usr/local/bin, and change the path of my svn program which the script expects to be in /usr/local/bin, but which gentoo installed in /usr/bin. Then I was ready to go.

Ready for Takeoff


I imported my two very special folders into subversion, but then I realized that, though this added them to the repository, it didn't make the original folders into working copies for me. There is actually a 'best practices' way of doing this, described in the Subversion FAQ.
svn mkdir file:///var/svn/repos/backups/etc
cd /etc
svn co file:///var/svn/repos/backups/etc .
asvn add *
asvn ci
I repeated the process for /home, and now my folders are all set up. I should be able to easily tell which files have been added or changed, revert back to an older configuration if I happen to screw anything up, and add in new files to be tracked. Once it's working smoothly, I'd like to automate some of it, so that my configuration is always saved when I shut down the computer.

Day to Day Stuff


It was a good thing I did all this when the system was shiny, new and clean. But, I quickly noticed a number of files in my home folder that I wouldn't want to have under revision control or in my repository at all. I wasn't too worried about sensitive data being on there, for a number of reasons. Most importantly, nothing will be stored in my repository until I add it to subversion in my working copy. But, as it turns out, I do have to take things into consideration, such as my web browser's cache. Well, subversion has a way to let you ignore these things, by setting a property on a file or folder. First, I created a text file with the list of patterns to ignore:
*~
*history
*.bak
*private
*[Cc]ache*
.ssh
Next, I set the "svn:ignore" property on my home folder to the contents of that file:
asvn propset svn:ignore -F svn-ignore-patterns.txt /home
Trackback URI: http://www.26a.net/index.php/trackback/4

Leave a Comment



Write the captcha code you are seeing.

Comment XML feeds: RSS | Atom