views:

1587

answers:

7

Long ago I tried to sort out my system between local, web server and subversion. I got some good explanation on this question.

Unfortunately I hit a road block on the whole pushing from SVN to a web server part and never revisited. All of my projects are solo, so I'm the only one developing them and often I'm the only user. So I've been able to get away with writing directly to the live server most of the time.

For 2009 I want to break that bad habit and actually do things the right way. I have SSH access to my web server (I can login and browse the files) but don't really know what to do in order to get the newest files out of SVN, into the server.

I've googled my fingers to the bone but everything I find requires some set of knowledge that I don't yet have.

I'd really, really appreciate step by step directions of how to automatically push the newest version of my code from an SVN repo to a live web server. FYI I'm currently using Beanstalk for Subversion hosting, but am totally willing to change that if someone has a better suggestion.

Thanks

+1  A: 

Hi there,

simply - login to your server machine and checkout the repository contents. This should be done just once.

$ svn checkout [http|svn|whatever_you_got_there]://{your_svn_repo} {checkout_directory}

Everytime you need to update your working copy with the newest one, perform update:

$ cd {checkout_directory}
$ svn update
ohnoes
This is alarmingly cool :) Any recs for SSH clients (using Putty at the moment) or ways to script this action (preferably using PHP)?
Evan
You really don't want to be checking out a working copy to your live server.
Steven Robbins
Steve, what do you mean? How would you perform an update then? o_O
ohnoes
ohnoes
If you do it this way make sure you configure your web server to disallow access to the .svn folders
gacrux
+1  A: 

Release Management

you can create an job/batch which exports the svn to a local folder. after the export you can upload it with rsync.

the job can automatically execute by the svn hooks.

you can also use mtod ways but keep in mind: using a checkout on the server is a security risk, if someone can access the .svn folders! they can access the php code and see passwords or bugs.

Bernd Ott
+6  A: 

If you have SSH access you could do:

svn export [url to repo] [web directory]

Export will mean you don't get the .svn baggage that comes with a working copy.

Steven Robbins
Thanks Steve, good info.
Evan
A: 

Unless your hosting company has given you access to either cron(1) or a shell, it will be difficult as svn, a centralised VCS, does not have a way to push things to a working directory, you are supposed to svn update.

Several ways to do what you want, depending on the above mentioned resources available:

  1. define a crontab(5) entry that does cd $WEBSITE && svn update
  2. use ssh to connect to your website and do the same command. The ssh can be automated by a crontab entry on your side.
  3. have a special cgi on your website, hopefully protected by password, that could be run periodically (from cron on your side) that does the same command.

Best way to me will still be moving to a decentralized VCS (like Mercurial or git) but that is a much bigger project.

Keltia
Defining periodical update is not a good idea, especially when dealing with production environment. Please notice that you may not want to have every commit updated. But even if so - see svn hooks: http://svnbook.red-bean.com/nightly/en/svn.reposadmin.create.html#svn.reposadmin.create.hooks
ohnoes
Keltia
A: 

I had a somewhat similar question some time ago, however I didn't have SSH access into my server so I was quite limited in my options.

Depending on the size of your project you might consider not doing an export. In my case the project was over a gig of data! Not practical because with an export you need to export all the files over and over again. If you only have a hand full of files it might be different. Also, doing an export on your local machine means that the export needs to download the file first and then upload it to your hosting which is like a waste of bandwidth.

Also keep in mind that doing an SVN export doesn't do any database updates. E.g., while you're developing your site your database will probably change may times. With just an SVN export you still need to manually re-import the database on the server.

What I suggest is that you write a script that you place on the server. You can make this script as elaborate as you want of course but the bare bone script would do an 'update' on a checked out version of your site, does an export of your database in a temp folder (your database is of course also placed under version control) and re-imports the database (or merges it, whatever it needs to do). With one single command you can then deploy your site. Over and over and over again.

There are tools that can help you with this sort of automation, like CruiseControl and Capistrano.

Luke
A: 

Hi Evan, have you tried using our FTP deploy on Beanstalk? We also have web-hooks available, which means you can ping a URL on each commit to code your own stuff.

http://help.beanstalkapp.com/articles/17-deployment-and-releases

A: 

Hi

I am using tortoiseSVN for windows .. and am a solo developer. I've configured it without a server & run it through GUI only. The only problem I am facing is, that I want to export the files from the repository that have "changed" from a certain revision, and not export ALL files .. so i can verify the changes before finally uploading them to the live server. I can't seem to find such an option in the software. It lets me export my project from a certain revision .. but then exports all files .. whereas I just want the changed files in the tree.

I will be really thankful if anyone can guide me on that.

Thanks.

nadshez