Rsync : Synchronize local with shared hosting
As web developer, We already realize that we are lazy. Our client is often only have shared hosting, not dedicated server that we can install version control which simplify push and pull. We often forgot to upload some file we changed/added in local to shared hosting, and it make web is not run properly in shared hosting. The solution is to use rsync in local PC. Rsync is a file transfer program for Unix systems. rsync uses the ‘rsync algorithm’ which provides a very fast method for bringing remote files into sync. An important feature of rsync not found in most similar programs/protocols is that the mirroring takes place with only one transmission in each direction. Rsync can copy or display directory contents and copy files, optionally using compression and recursion.
So, you need to know the step to do this :
1. Go to your Cpanel
2. Click Ftp Account
3. Click Configure FTP Client in your desired user
And see the SFTP Port. Use the port to in rsync port target transfer.
4. Start syncing…
cd ~/www && rsync -timeout=50000 -av --exclude ".git" --exclude ".gitignore" --exclude "wp-config.php" wordpress_local_dev/ -e "ssh -p 2223" email@example.com:/home/yourremoteserveruser/public_html/
The option –exclude will exclude unneeded to sync.
The option -timeout is what second to be connection to timeout.
And you will see the following ( just updated / added file will be uploaded ) :
5. Done !
Image : http://www.haykranen.nl/wp-content/uploads/2008/05/timemachine.jpg