Webserver Synchronization and Code Storage

Learn how to setup file synchronization to automate deploying updates to your website. This project uses several programs that are all open source and free to use. It also uses a mix of Windows and Linux (Ubuntu). It requires having SSH access to your webserver.

Technologies / Programs used:
Subversion (SVN) is used to store and organize your code. It is typically used in a team environment, but I find it just as useful for a sole developer. This guide is written using version 1.7.
SVN Server
SVN Client
  • Tortoise SVN (windows): Check out and commit files and folders directly from windows explorer.
  • Subclipse: Integrated SVN control with Eclipse.
Editor
  • Eclipse PDT: PHP development variant of Eclipse. Good for large projects.
  • Notepad++ (windows). Good for editing a few files at a time.
  • Emacs (linux, cygwin). Good for quick edits.
Linux Environment
  • Ubuntu: Easy to use linux distribution based on Debian
  • Cygwin: Linux environment that runs on windows.
Linux Programs
  • rsync: (Ubuntu: apt-get install rsync) (Cygwin: in setup.exe it is located under Net)
  • *rsync needs to be installed on the remote machine, in my case it is not :-(
  • OpenSSH: (Ubuntu: agt-get install ssh) (Cygwin: in setup.exe it is located under Net)
  • *OpenSSH is nice to access the remote server, but it is not needed for this project.
  • unison: Can synchronize files mounted to the local file system with SSHFS
  • SSHFS: Mounts an SSH directory to your local file system for synchronization with unison. (not available in Cygwin)

 

(work in progress)

Step 1: Install Editor

Step 2: Install SVN

Step 3: Setup SSH on your webserver

Step 4: Setup unison

Step 5: Automate with scripts

Linux

mount ssh script:

#! /bin/bash

sshfs username@domain.com:/directory/ /home/mike/ssh

unison to synchronize:

#! /bin/bash

svnPath=”http://festatools.svn.sourceforge.net/svnroot/festatools/FestaTools/”

localPath=”/home/mike/svnExport/gametraderworld/FestaTools/”

remotePath=”/home/mike/ssh/gametraderworld/FestaTools/”

svn export $svnPath $localPath –force -q

unison $localPath $remotePath -prefer $localPath -batch -maxthreads 2

Unmount filesystem:

#! /bin/bash

fusermount -u /home/mike/ssh

 

(work in progress)

Tagged , , , . Bookmark the permalink.

Comments are closed.