The poor's man "dropbox"-thing


This recipe shows how to setup a basic synchronization mechanism (similar to DropBox) by means of conventional GNU/Linux tools. This does not require root privileges and no packages (except ssh-server) need to be installed in the server.

WARNING: This procedure may cause data loss. Use it under your responsibility


In the client:

  • cron
  • incron

In the server:

  • ssh server

The server should be accessible from everywhere and configured for using ssh public key authentication. Nothing else needs to be modified in your server.

The “poorbox” script

Put that in your ~/bin/

#!/bin/bash --
# {to-host|to-server} [file EVENT]
set -e
case $1 in
 * )
    echo "usage: $0 [to-host|to-server]"
	exit 1
# avoid reentrant execution
flock -n $LOCK-$1 true
if [ "$3" == "IN_DELETE" ]; then
	CMD="ssh $SERVER rm $FOLDER$2"
	CMD="rsync -avz --delete $SOURCE$2 $TARGET"
# wait for the inverse transfer
flock $LOCK $CMD

Synchronizing host to server

The next configuration will copy or delete any modified file from your laptop/PC to your server account. First, you need to put your username in the /etc/incron.allow file.

Run that in a terminal:

$ incrontab -e

Your default editor will start. Write down next line, save and close.

/home/john/PoorBox IN_MODIFY,IN_DELETE,IN_CLOSE_WRITE,IN_MOVE /home/john/bin/ to-server $# $%

and then:

$ incrontab -d

Synchronizing host from server

We will not detect changes in server files (although may be possible using the same way). We will poll changes using cron. Run next in a console:

$ crontab -e

write and save next line:

*/1 *  *   *   *     /home/john/bin/ to-host

This poll each minute. Of course, you may increase or decrease the polling frequency as you prefer.

Improving performance

Continuous ssh connections does not seems a good idea, but it is possible tweak your config by means of ControlMaster and KeepAlive ssh options.


Currently incron does not detect recursive events (operations on subdirectories)



Opciones de visualización de comentarios

Seleccione la forma que prefiera para mostrar los comentarios y haga clic en «Guardar las opciones» para activar los cambios.
Imagen de magmax

Another option

Do you meet "unison"[1]?

It is Debian package.


Miguel Ángel García

Imagen de david.villa

yep, I know it, but it is

yep, I know it, but it is only a rsync front-end. The requirement here is transparent remote update.

No soy portavoz de ningún colectivo, grupo o facción. Mi opinión es personal e intransferible.

Imagen de int-0

Maybe... can use FUSE and this to do that... Laughing out loud

$ python -c "print 'VG9udG8gZWwgcXVlIGxvIGxlYSA6KQ==\n'.decode('base64')"