How to deploy a web application and to quickly deploy future updates/patches from a SVN repository into a remote web server (only with ftp access and without possibility to setup svn client) ?
Here are my suggested steps:
- export SVN (that is obtain the last repository without “.svn” directories)
- process the exported SVN (e.g. adding or deleting files before uploading)
- upload (1st time) or synchronize (update new files to the remote webserver)
- chmod folders (only 1st time or new folders)
All the 4 steps are executable from a handy shell script using:
Example of a svn to ftp batch in Windows (with subversion client and winscp, both are free):
- Create a profile with winscp, and set local folder “c:tempsite1” and remote folder (e.g. “/httpdocs” ).
- Write a batch file svn2ftpsite1.bat
svn export svn://22.214.171.124/trunk %PATHFOLDER% –force
del %PATHFOLDER%file-not-to-upload* /q
copy c:other-folderfile-to-add-to-site1 %PATHFOLDER%
c:path-towinscp.exe /console “open winscp-profile” “synchronize remote” “chmod 777 uploads” “close”
- Save. And launch when you want to update the remote site (don’t forget to commit the svn before)
Read the winscp online scripting manual for further information.
Note: if the web server (Linux I think!) can access the SVN repository, has SSH server and subversion client, you can export directly the repository in the web server.
Note: if the web application works correctly, take note of the current repository version. in case of future problems you will be able to export that revision (svn client command line option) and restore the online web site.
Note: If you can install svn client in the web server and the repository is visible from the web server, you can use “check out” and “update” directly in the webserver, then use an apache rule to hide .svn directories
RewriteRule /.svn /errorpage