Web International Awards

payday loan

15

FEB 2011 0

Drop ftp and switch to unison

Preview of unison

This article is directed to those of you who use on a daily basis any FTP program to transfer files back and forth between computers, development and production environments and more. Doing it via FTP comes handy compared to file uploading plugin in CPanel or Plesk for example, but when it compares to rsync or unison, FTP seems so old and time consuming.

Not familiar with rsync or unison?

Rsync is an open source utility that provides fast incremental file transfer. You can easily use it to backup your disk, upload files onto a test server while coding them locally. There are some great things you can do with this tool:

  1. Initiate synchronization between two folders (and their sub-structure). These folders could be a local folder of a webapp and its public server brother. It may very well be your root folder on your pc and the root folder of an external backup disk.
  2. Start modifying files in any of the two folders, then sync the other one. This can help you easily write your code locally and deploying it on the server, or backing up vital data onto an external harddisk.
  3. Restore files you've deleted or ill modified from the secondary folder (backup).

And the list doesn't stop there. The possibilities of rsync are great...up to a point. Rsync doesn't do bi-directional transfer unfortunately and this has become, to me at least, a major drawback. You'd jump to say that I've stated the exact opposite just above. Yes, you can move files both ways with rsync, but in the case you've modified some in folder1 and some files in folder2, you won't be able to sync and keep all modifications in place by using merging. You'll have to choose which modifications to let go (which is unlikely to be the case) or do the sync yourself. But then, what would be the point of using rsync as it doesn't do much good?

Fortunately, there's a better tool called Unison which does mainly the same things as rsync, but is capable of synchronizing data both ways. If you modified files in both folders, you'll keep all modifications as Unison will transfer from one point to another the most recent files. If the same file has been modified on both ends, Unison will detect the conflict and ask you how you want to proceed. Now this is a really great and powerful feature.

Now why would you drop FTP in favor of these two?

Imagine you've got a project that has more than 100 folders, more than 1000 files, and after a bugfix you've modified files in 10 directories. The average user that hasn't any system setup or repository would write down modified files, and then browse the hard drive and the FTP account and copy/paste each file one by one, or in lucky cases, multiple at a time.

Anyway, you'd have to be really lucky to do all files in one shot. With rsync or Unison, you'd do them all in one shot, without to much worries. Moreover, if you find yourself out of the office and need to do a quick and simple fix, you can even do it directly on the server and then sync it back to your local folder. Wouldn't this be great?

Check out some more information about rsync or Unison.

Published on Tuesday, February 15th, 2011 at 11:54 pm in articles, tutorials.

About Bogdan Pop

Bogdan Pop is a young Romanian entrepreneur who runs WebRaptor. He is a web developer with awesome design skills, who enjoys writing about everyday's work and usability. He relaxes by taking photos every once in a while and by mixing french electronic music. Connect with him via Twitter.
 

There are no comments. You can be the first to post one.





Save time next time! You won't have to fill out all these fields again. Register in just a few clicks and then login.


If you do not have a username, you can register in just a few clicks.