File Synchronization with rsync

Microsoft SyncToy is a very helpful tool for 1-way or 2-way file synchonization. But it hasn’t been updated since 2009 and of course its not for Linux 🙂

rsync

Its a very good command based tool which can get the 1-way file synchonization done neatly (the logo does look unprofessional but this tool isn’t).

Installing rsync on Ubuntu

It is by default installed on Ubuntu (tested on both 12.04 and 12.10 distributions) but incase it isn’t, then run the following command:

sudo apt-get install rsync

Structure of rsync command

Following is the structure of the simple yet powerful rsync command:

rsync [options] [source-folder] [destination-folder]

Possible options

  • -a or –archive can be used for archive which means timestamps and ownerships will be retained.
  • -z or –compress can be used for compress mode which means bandwidth can be saved but CPU power will be consumed
  • -v or –verbose can be used to display information when rync is transfering, otherwise it does so silently.
  • -n or –dry-run can be used to display what will happen if this rync command is executed. No changes will take place
  • –progress does what the name says. It will display the %age, transfer rate etc.
  • –size-only will compare files based on their size instead of hashes. This way less CPU power is will consumed.
  • –delete will delete all the files from the destination folder that are not present in the source folder.

Source and Destination Folders

The trailing slash / at the end of the destination is important.

Fix Dropbox “Unable to monitor filesystem” error in Ubuntu (Linux)

Dropbox is in my view the best cloud based file synchronization service. Recently I started getting this error on my Ubuntu OS Unable to monitor filesystem. The screenshot is:

Dropbox Error - Unable to monitor filesystem

Dropbox Error – Unable to monitor filesystem

Additional instructions were (as mentioned in the screenshot) Please run “echo 100000 | sudo tee /proc/sys/fs/inotify/max_user_watches” and restart Dropbox to correct the problem

To my knowledge, there are three ways of fixing this problem:

  1. Run the command as instructed
    Open up the terminal window, type the command:

    echo 100000 | sudo tee /proc/sys/fs/inotify/max_user_watches

    and restart dropbox. Restart can be done manually by right clicking on the icon and selecting “Quit Dropbox” and then start by typing Dropbox in the Unity Dash. Or simply run the following commands:

    sudo dropbox stop
    sudo dropbox start

    This will fix it as long as your system is running. After a restart, these settings will be cleared.
    Update: Also note that for starting the sudo can be skipped also as mentioned in the comments.

  2. Add the command to the rc.local file
    This file (script) is run at the end of each multiuser runlevel. Open this file in the editor with the following command:

    sudo vim /etc/rc.local

    Add the following before the exit 0 line:

    echo 100000 | sudo tee /proc/sys/fs/inotify/max_user_watches

    This will fix it even if your system restarts.

  3. Add the command to the System Configuration File
    Open the System Configuration file (sysctl.conf) using the command:

    sudo vim /etc/sysctl.conf

    Add the following line at the end:

    fs.inotify.max_user_watches = 1048576

    Although the changes have been saved but have not yet been applied. To apply either restart your machine or run the following commands:

    sudo sysctl -p
    sudo dropbox stop
    sudo dropbox start