[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Automatically posting committed changes to production server

From: Bob Proulx <bob_at_proulx.com>
Date: 2005-05-08 18:40:05 CEST

Jim Burton wrote:
> I've also been asked to set up this scenario in our web shop but the
> live webservers are outside the firewall with no chance of tunneling
> etc so update or deploy are no use. So I'm thinking we need a
> post-commit hook that uses FTP to move the updated files across. Can
> you point me to an example of something similar?

It would be useful to show us a simple diagram or discription of what
is allowed from where to where. Until then I will assume the

                            | |
   +------+ |F| +------+
   |svn | |i| |web |
   |server| |r| |server|
   +------+ |e| +------+
   +------+ |a|
   |svn | |l|
   |client| |l|
   +------+ | |

If you can ssh from svn server to web server then instead of ftp use
ssh. ftp is not a secure protocol and you should avoid it in insecure
environments. Use ssh instead. I recommend using 'rsync' over ssh.

File post-commit:

  # Assume "/srv/www" is a working copy owned by a 'www-data' user
  # writable by the web server process. Could be located anywhere.
  cd /srv/www || exit 1
  svn update --quiet
  rsync -a --delete --exclude=.svn ./ webserver:/srv/www/
  exit 0

Of course newer versions of rsync use ssh by default as the transport
mechanism. If you are using an older version you would need to either
use the '-e ssh' option or set 'export RSYNC_RSH=ssh' in the

You would need to ensure a passwordless ssh connection between
svnserver and webserver. The following should have no output and
return true for the 'www-data' user.

  ssh webserver true </dev/null

Usually in the above type of script I would actually redirect all
error output to a log file and I would have it automatically mail me
any errors from the operation.


To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Sun May 8 18:41:54 2005

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.