PaulDotCom mailing list archives

backing up /etc using svn


From: mailing at vankets.com (Bert Van Kets)
Date: Mon, 10 Aug 2009 17:14:14 +0200

You can do it but it's a multi step process.

*One time setup*
- Copy all the config files to a "config directory"
- Use the inport command to add the data to Subversion
- Delete the files in the "config directory" and Export them from the
SVN repository. This will create the .svn sub directories containing the
versioning information.

*Daily updates*
- rsync all your config files to the local "config storage" directory.
- Commit the changes to the SVN repository using a cron job

This will give you the ability to check the log of the changes and use
diff and merge to check and use the changes between two config versions.

There is one little caveat and that's the files that are removed and the
files that are added. New files need to be added using the "avn add"
followed by the "svn commit" command. Config files that are removed from
the /etc directory will still be present in the latest svn version
unless you remove it using the "svn remove" and "svn commit" commands.

I use this system to keep versions of scripts in windows. My batch file
does the following steps
- remove the data files from the "versioned dir" leaving the .svn
directories in place. I use the fact that the .svn directories are
hidden and read only and are thus not removed by the del command.
- automatically grab all the scripts and place them in the "versioned dir"
- Check for added files and "svn add" them using the folling command
svn st | grep "^?" | awk "{print $2}" | tr "\\" "/" | xargs -i -t svn add {}
- Check for removed files and "svn delete" them using
svn st | grep "^!" | awk "{print $2}" | tr "\\" "/" | xargs -i -t svn rm {}
- run "svn commit" to send all possible changes to the subversion
repository.

Adjust the commands to Linux if needed. You will probably be able to
skip the tr command.
This method will only create a new version when something in the files
has changed. You will be able to request a log for each file and verify
the changes.
You will manually have to roll a config file back if needed and copy it
to the /etc directory.

Hope this helps a little.

Bert

Robin Wood wrote:
Hi
I'm looking at different back up solutions for my server and was
thinking about using subversion. I'd add /etc to a repository and have
it automatically checked in every night. I'd have the repo to be on a
different server and to have the svn traffic tunnel over ssh.

As some files in /etc are only readable by root, the svn check in must
be done by root. As allowing remote ssh access to root is a bad idea
so the repo must be owned by a non-root user on the other box. Seeing
as I'll have to trust something somewhere I'll assume that I trust the
non-root user on the other box.

Before the check in all new files must be added to the repo as well.

Does anyone else have this kind of setup and if so, does it work or
can you point out any alternatives or better ways to do things?

Robin
_______________________________________________
Pauldotcom mailing list
Pauldotcom at mail.pauldotcom.com
http://mail.pauldotcom.com/cgi-bin/mailman/listinfo/pauldotcom
Main Web Site: http://pauldotcom.com
  



Current thread: