Ask YC: How do you upload to your web server?
Hi. I was wondering how you upload your code from localhost to the web server. Right now, for my project, I upload the entire directory from localhost to my web hosting server and replace the existing files with the newly uploaded files. It was ok in the beginning because the files were small. Now that I have a bunch of libraries, it takes quiet a long time to upload all 600 files every time I upload.
I recently learned about rsync to upload only changes. I was wondering if you use this or other tools to upload.
47 comments
[ 3.3 ms ] story [ 92.3 ms ] threadserver: $ mkdir /www/pages/project $ cd /www/pages/project $ hg init
localhost: $ cd /path/to/your/project $ hg init $ hg add * $ hg commit -m "message" $ hg push ssh://usr:pwd@123.123.123.123//www/pages/project
afterward it's just the localhost (ignore "$ hg init")
Heck, I use sshfs to mount my blog as a directory & edit files directly. rsync has also worked nicely for me in the past. But then, these are all sites that I either don't care about source control, or don't have git/hg available on the shared server.
hg qpop -a ; hg pull ; hg update $1 ; hg qpush -a
The $1 is a branch or tag argument given to the Bash script. That way you can easily specify a particular version to update to (or rollback to!) on the command line.
The qpop and qpush will rebase any MQ patches you've made, e.g. local configuration changes, hacks, etc.
More on rebasing applied patches with Mercurial: http://hgbook.red-bean.com/hgbookch12.html#x16-28900012.8
bzr push to a REP on the server login over ssh on the server bzr export REP run the test suite on the server (last check) cp relevant files to PROD restart the server (FastCGI)
everything automated and sequential one failure -> process stops completely (never happened so far)
You may choose to use a tool to run your update scripts automatically and create configuration files correctly, but you'll want to think it through in advance. A particular problem I have is that certain sensitive passwords should not exist anywhere but in the locations they are required, so even pre-created configuration files still require me to manually enter the password once installed on the server.
If you're deploying code, you really should be using Capistrano. Even if it is not a Rails project. It is a world of difference.
It turns updating your server from a mild headache to one line that you actually enjoy typing in.
http://pypi.python.org/pypi/Fabric/
http://code.google.com/p/boto/
Yes, I'm going against the grain by using Puppet instead of Capistrano. All the Rails people are probably going to crucify me, but I personally think this setup works quite well.
Use WinKey to map win-P to project.bat.
project.bat: rsync -Crltvz -e ssh /cygdrive/c/personal/project/ me@mydomain.com:/bigfiles/project
then I can just hit win-P to force the rsync. Runs in a couple seconds even with hundreds of files.
But my favorite if I don't need version control is to use <a href="http://www.sftpdrive.com/">sftpdrive</a> to mount the remote server as a local disk. It is $39, but is probably my favorite windows software. I've done the Samba thing and like this much better.
http://www.novell.com/coolsolutions/qna/999.html
On the server there are Dev, Staging, and Production environments. Dev and Staging are bare checkouts from the git repo. I have deploy shell scripts that automate deploying to both (checking out from source control and running database migrations). The process should be that code is deployed to Dev, then Staging and finally to Production.
The Production environment is NOT a checkout from source control. It is an exact mirror of the Staging environment. And the deploy script to production does the following:
- tags source control with the new release number
- creates a tar.gz backup of the production directories
- does a database backup dump
- then uses rsync to copy files from the staging web directories to the production directories.
- lastly runs migration scripts on the prod database
http://tortoisesvn.tigris.org/
rsync -azP local_dir -e ssh user@host.com:remote_dir
It's not very professional, but for our needs it's perfect.
The update command does something like this:
* Check out all pertinent application files from the repository.
* Add any production specific files, for example build number or database setups
* Combine, compress, and number all Javascript and CSS files (combined.384.css can be cached forever, on update it becomes combined.385.css)
* Tar and gzip the production files
* Find all EC2 servers that need to be updated
* Upload the gzipped files
* Stop apache
* Remove old files on the server(s)
* Unzip the new files
* Start apache
> svn update