rsync Backup / Dropbox style setup

Introduction
This tutoral/HOWTO is designed to help you setup an rsync back/dropbox style synced folder on the Netgear stora. The aim of this is to have a synced folder that will automatically back up to a remote location. The main reason that I wanted to do this was so that I could have a folder of documents backed up to my VPS and synced to my work machine and laptops.

It is similar in style to the ‘dropbox’ service. It is largely based on this HOWTO. It just covers a number of points for installing on the Stora!
This guide assumes you have a fully working package management system as described here – Installing a package manager and also assumes that you have SSH fully working.

SSH Setup
Setup your ssh keys to your remote server by doing the following:
  1. Generate your keys (don’t enter a password – this enables you to have the syncing done without user intervention!) ssh-keygen -N -f ~/.ssh/id_dsa
  2. Copy public key to server so you can login ssh-copy-id -i ~/.ssh/id_dsa.pub user@REMOTE_SERVER
  3. Tidy up permissions ssh user@REMOTE_SERVER 'chmod 700 .ssh'
  4. Check you can login without a password ssh user@REMOTE_SERVER

Software Install

  1. Now prepare for the lsyncd build by installing the following packages by running the command sudo ipkg install <pkg name>
    1. gcc
    2. lua
    3. make
    4. pkgconfig
    5. rsync
  2. Download and untar lsyncd from the lsyncd project
  3. Configure the build by running ./configure --prefix=/opt/local --exec-prefix=/opt (this assumes your addition software is on /opt, otherwise tailor to your needs, but avoid the onboard flash!)
  4. Modify the Makefile to set the following:
    1. LDFLAGS = -ldl
  5. Assuming you got no errors from the configure do make all
  6. Now do sudo -E make install (the -E just utilises the same environment settings of the current user as when doing sudo PATH seems to disappear and it won’t be able to find the commands!)
  7. Now run sudo ln -s /opt/lib/liblua.so /usr/lib/liblua.so so that lsyncd can locate the library
  8. Now run lsyncd -help to see if all is well (you should get a list of options)!

Configuration

(Please refer to the lsync manual for comprehensive guidance)

  1. Copy example/lrsyncssh.lua to a location of your choice (I created $HOME/sync_config)
  2. Fill out the configuration file sync_conf.lua with the appropriate details (the file can be put anywhere):

sync{default.rsyncssh, source="/path/to/src", host="user@REMOTE_SERVER", targetdir="/path/to/dst", rsyncOps=""}

  1. Run lsyncd in no daemon mode to check for errors:

lsyncd -nodaemon sync_conf.lua

  1. Drop some files in the watched directory and make sure they get uploaded properly with no errors
  2. Run lsyncd in daemon mode to have it watch the folder:

lsyncd sync_conf.lua

Reverse Sync

Adding the following crontab line is particularly useful if you want to have your laptop or other machines sync up, or at least have the Stora pull from the remote server.

* * * * * rsync -ltur user@REMOTE_SERVER:/path/to/src/ /path/to/dst >> /path/to/log/dir/rsync_pull.log

Final Comments

This setup can be replicated on your laptop and work machines to create the full dropbox like experience.

This entry was posted in Howto, Server Admin and tagged , , , , , . Bookmark the permalink.

2 Responses to rsync Backup / Dropbox style setup

  1. axkibe says:

    Hello, thank you for this well done guide!

    You are the second one that reports having to add “-ldl”. Some systems need it, some don’t, I dont know yet how to autodetect for it. You can change LDFLAGS with a normal configure call.
    LDFLAG=-ldl ./configure –prefix…
    should work as well.

  2. Ap says:

    Thanks for the write-up! I wonder if this can be done on a x86 QNAP too…

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.