FTP Synchronise
July 20, 2008 7:45 AM   Subscribe

How do I do a one-click ftp synchronisation and server restart - using only free software?

Here is my situation - I am using eclipse to develop a django application, that is hosted on webfaction. Whenever I do a change and I want to test it on the server, I need to

1. Open my FTP client
2. Select the items or folders that have changed
3. Upload them
4. Open ssh and login
5. Navigate to my apache directory and restart it

Ideally, I would like to just push a button, wait a couple of minutes and everything is online. My idea at the moment is to install cygwin locally, and write some type of shell script that would do this for me - would this work, and if so, how would I do this?

I tried installing the ftp synchronisation plugin for eclipse, but it seems to have disappeared.

Is there any more clever way to solve this problem that I don't know of?

(I'm using Windows XP, by the way...)
posted by markovich to Technology (8 answers total)
 
Well, what I did for pretty much the same problem is have my project under SVN control, so when I'm ready to make changes, I commit, and then I have an update.sh on my server that does:
cd project/dir
svn up
apachectl restart

svn takes care of the delta changes, and source control is smart anyway. with cygwin, you could run the script locally with 'ssh root@myserver /project/update.sh', and you can even do ssh key exchange and make a shortcut so its one click.

i fucking love django btw
posted by Mach5 at 8:14 AM on July 20, 2008


It's focused on Ruby on Rails deployment, but you might take a look at Capistrano, which was designed for these sorts of challenges.
posted by Alterscape at 11:01 AM on July 20, 2008


If your host supports svn, you can streamline Mach5's approach a bit by creating a post-commit hook that runs the update script. This is what I've done with a work project. I have the web server root checked out from the working copy. On my development machine I check out a copy of the same, modify it, then commit my changes.

When I commit the changes the post-commit hook causes a script to run which executes svn update as the web server user on the webroot directory.
posted by odinsdream at 11:47 AM on July 20, 2008


Just to check: are you testing this on your live server? That's a bad idea. Much better to set yourself up a local sandbox, on which you can test to your heart's content, then upload once you're ready. It'll make your development much faster, to boot.
posted by bonaldi at 11:50 AM on July 20, 2008


I'm testing locally, but I only work on tiny features, then I send to live site. This process of updating to live site takes near to 10 minutes, which is an awful lot of wasted time.
posted by markovich at 1:22 PM on July 20, 2008


If you have scp access, you don't want to muck around with lossy ftp and trying to identify what has changed. There is already an app for that: rsync

First, I would set up an ssh pubkey and put it in the known hosts on the target server (so you no longer have to supply a password for ssh when you connect from your local cygwin install) This part is critical to automating the rest.

Here's an article about password-less ssh


Next, I'd whip up a little shell script like this:

/bin/bash

rsync -uavz /your/local/http/docs/repo user@remoteserver:/path/to/htdocs/folder/on/apache;

##then execute remote command with ssh

ssh user@remoteserver "apachectl graceful";


and viola you're done. ssh automatically takes a second argument as a remote command to execute.
posted by judge.mentok.the.mindtaker at 1:33 PM on July 20, 2008


(please forgive the semi-pseudo code ... lmk if you need exact syntax help.)
posted by judge.mentok.the.mindtaker at 1:38 PM on July 20, 2008


I'm too lazy to set up scripting for work as minimal as this - I'd just use the FireFTP extension for Firefox to do my uploads (it opens in a Firefox tab, which I'd just leave open all the time) and I'd also just leave a window open to a server ssh session that I only ever used for restarting the web server. Assuming the server's running bash or something like it, just hitting the up-arrow key and Enter in that window repeats the last command.
posted by flabdablet at 8:53 PM on July 20, 2008


« Older A Superb Cat Supplement. Where?   |   How do I navigate Newark Airport? Newer »
This thread is closed to new comments.