fredag 19 september 2008

Svnsync automatisation via Windows Scheduler

Recently I've been setting up for a project, as you might have noticed, and one of the problems we ran into was the fact that we have a centralized subversion repository. We don't have access to control or install anything on the actual server unfortunately, so hence we can't install trac on that system, as previously explained. The solution is to sync the main subversion databases to the trac server as previously explained.

A secondary problem arising from this, is that we can't actually change the hook files of the master repository. The solution to this, is to add a synchronizing scheduler. As I was stressed, and had no time to deal with this properly, I had to run with the Windows Scheduler of all horrible solutions. The following explains how to set it up.

Windows Scheduled synchronize Task

Warning!
The windows scheduler does not start automatically when you reboot etc. If you do this, the task restarts at it's start time, so if it's set to run at 00.00 every day, and then every 5 minutes, it will restart and start running at 00.00, not as soon as the machine is started up again. This is pure evil.

A scheduled task is set up as follows, create a bat file (ie, c:\projects\svn\project\svnsync-project.bat):
svnsync synchronize http://localhost/svn/project --sync-username slaveuser --sync-password tjohej --source-password password
c:\Python25\Scripts\trac-admin.exe c:\projects\trac\project\ resync
The Second line unfortunately has to be done to resync the new changes with the trac database. After this, create a scheduled task in windows as follows:
  1. Go to start -> control panel -> scheduled tasks
  2. Click Add scheduled task
  3. Click Next
  4. Click Browse...
  5. Browse to your svnsync-project.bat file, as described above. Double click it.
  6. Set name (default is ok). Perform this task: Daily
  7. Click Next
  8. Start time: 00:00, Every day, Start date: today
  9. Fill in username/password to run it as.
  10. Select open advanced properties for this task. Click Finish.
  11. Go to tab Schedule. Choose Advanced.
  12. Click Repeat task, fill in Every 10 minutes, and click Time and fill in 23:59
  13. Click OK.
  14. Click OK
  15. Done.
This could most likely be done from cruisecontrol, but as stated, i'm stressed. I hate windows by now (at/cron is just sooo much nicer to handle).