Whereas SSH Keys come primarily from the sysadmin realm, the next tool I’d like to introduce is most often associated with the programmer’s toolkit. Subversion (SVN), or more generally, revision control software, allows you to do away with littering your production systems with tons of backup files, and consolidates your files into one place that’s easy to backup, duplicate, and modify. Programmers typically stuff source code, makefiles, and supporting documentation into SVN; I use it not only for that, but for /etc/ files, kickstart configs, shell scripts, and more. Some of my systems — in particular my puppet server — pull from subversion via a cron job, others use puppet to push files as needed, and others I push files to manually. Eventually I hope to put a great deal more data in SVN, such as much of our website, but for now, I’m starting out slow.
So, what to do?
- Find a reliable space to store your repository, which is essentially the authoritative copy of your files. This space needs to be reliable, and should be easy to back up. Subversion (and most other RCS systems) will work with a variety of access types, but primarily I find direct filesystem access over NFS and remote access via SSH to be the most common use cases*. For the purpose of this discussion, we’ll call it /export/svn/foo
- Install subversion on the chosen system. Most *nix systems will have a subversion package; if not, there’s a link to their website at the top of this post.
- Run svnadmin to initialize the repository. ’svnadmin help create’ will give you some info on the options available to you, but generally ’svnadmin create /export/svn/foo’ is the form of command you want here.
- Install subversion on your client system; soon I’ll be posting information on good Windows-based clients for subversion, but right now I’m going to punt on that and assume we’re using *nix.
- Check out a working copy of your empty repository:
cd ~
mkdir svn
svn co file:///export/svn/foo ~/svn/foo
– or over ssh to a server called myhost.com –
svn co svn+ssh:///export/svn/foo ~/svn/foo - Copy files into the working copy, or start creating new files.
- Add the files into SVN, using svn add …
- Commit your changes back to the original repository, using svn commit -m “Log Message Goes Here” ~/svn/foo/
Obviously, there’s a lot more to managing source files, but this is a start. Note that if you’re using SSH to connect to a remote repository, SSH keys will save you a lot of typing!
* If you’ve ever used a code.google.com project, you may have noticed that they use SVN. If you have commit access, you’ll use authentication over HTTPS to do commits. SVN is capable of storing your password in your working copy in this case, but it’s beyond the scope of this particular post; go forth and Google it!
