SVN to FTP/web on Windows with svn client+winscp

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:

  1. export SVN (that is obtain the last repository without “.svn” directories)
  2. process the exported SVN (e.g. adding or deleting files before uploading)
  3. upload (1st time) or synchronize (update new files to the remote webserver)
  4. chmod folders (only 1st time or new folders)
All the 4 steps are executable from a handy shell script using:
  • Linux: svn client (1) + rsync (3)
  • Windows: svn client subversion (1) + winscp script (2)
Example of a svn to ftp batch in Windows (with subversion client and winscp, both are free):
  1. Create a profile with winscp, and set local folder “c:tempsite1” and remote folder (e.g. “/httpdocs” ).
  2. Write a batch file svn2ftpsite1.bat
    set PATHFOLDER=c:tempsite1
    svn export svn:// %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”
  3. 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