Robust subversion sync via cron

I usually deploy my projects using subversion. This means that on a given server I'll do an initial checkout, typically of the live branch. Then I'm setting up a cron job that on regular intervals polls the distribution server and checks if there are any new versions available. If they are then the scripts syncs to the new revision(s) and performs any additional optional operations (e.g. doing a 'touch' for WSGI reload etc).

One of the problems I ran into was then whenever I submitted a change on the dev branch the sync script would consider this to be a new version because the highest revision number in the depot changed - but of course the change was in the dev branch only so no reason to sync and do other possibly expensive post-sync operations...

I've finally figured out how to solve the problem - I'm detecting the latest version that I've checked out on the deployed machine and then use svn log to see if there are any changes in that branch after that revision. The nice thing about log is that by default it only checks for changes within the given branch (i.e. just what I needed).

I'm attaching my skeleton sync script that I usually use for deployment. Simply adjust the SVN_USER/SVN_PASS variables at the beginning, and add any other custom post-sync commands at the bottom - that's it!

svn_cron_sync.sh (828 bytes)

Next entry

Previous entry

Similar entries


Comments

No comments yet.


Pingbacks

Pingbacks are closed.


Trackbacks

Post your comment