Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a nightly svn commit script that should take into account all possible scenarios and commit new things to our svn repository. Basically I am running the following steps:

  1. svn status [path] to add any new files
  2. svn status [path] to delete any manually removed files
  3. dumping mysql development database
  4. svn commit all the above changes with a default message.

Here is the script that we are using:

echo "Adding new files to the nightly commit"
svn status  [path] | grep ? | sed 's/[?MD]//g' | xargs  -I {} svn add {}
echo "Removing files manually deleted"
svn status  [path] | grep ! | sed 's/[!]//g' | xargs -I {} svn del {}
echo "Dumping our development database"
mysqldump  --add-drop-database --add-locks --create-options --disable-keys --extended-insert --result-file=/repopath/database.sql databasename
svn commit /repopath/ -m "Nightly Automatic commit of changes"

I just want to make sure that the ? and ! are taken care, and that I don't have any other scenarios that I have not think of. Any help will or improvement to this script will be very helpful. Feel free to use this script as you please for any of your SysAdmin tasks.

share|improve this question
  1. "xargs svn add" should be enough, why are you using -I {} ?
  2. I wouldn't do this at all. You'll probably get a lot of tempfiles in SVN. You may put a CD-image there one day.
  3. I wouldn't do this. Your comment will be completely meaningless. What did I change, etc? Why not just commit when you have actually changed something?
  4. Mysql is evil sometimes. You need to make sure that the database dump is actually OK. Are you reading the stderr output from the script in the morning?
  5. With time, your repo will get really big (depending on DB size and changes), with no good way to shrink it.
  6. You'll want to escape both ! and ?. Or quote them. With singlequotes, '!' will work, "!" can cause trouble.

In summary: I think you got everything covered (except point 6), but I wouldn't do this if I were you.

share|improve this answer
Thanks Thomas, your comments are very valuable. We have to go this route due to a design flaw that we currently have in one of our systems. We are working towards solving this design flaw. thanks again. – Geo Jun 29 '09 at 13:32

You can also go svn add on all the files in your directory. Files that have been added already and are already under version control will generate an error message, but it'll add all the new ones.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.