Syncing config files to a subversion repository automatically
Here’s a script I cooked up for syncing my Web server’s config to a subversion repository.
Before running the script, initialize an svn repo at /root/subversion/serveurs-web.
#!/bin/bash # Path to the previously created SVN repo svnpath=/root/subversion/serveurs-web # use rsync to copy config files from /etc to svnpath. Allow delete, but don't touch the .svn folder rsync -auz --delete --exclude=.svn /etc/lighttpd $svnpath/web1/etc/ rsync -auz --delete --exclude=.svn /etc/php5 $svnpath/web1/etc/ #svn status $svnpath # svn auto delete, add and commit script stolen from http://blog.sosedoff.com/2009/01/16/svn-auto-add-and-delete/ echo "processing files to add..." svn status $svnpath | grep "^?" | sed -r 's/^\?[ ]+//' | xargs -r svn add echo "processing files to delete..." svn status $svnpath | grep "^!" | sed -r 's/^\![ ]+//' | xargs -r svn delete echo "processing commit..." svn commit $svnpath -m "automatic commit from $HOSTNAME" # done! |