I am trying to create a personal sync system for my project. I don't want to use something like dropbox, bittorrent sync, owncloud etc for various reasons.

At the moment, I have my computers setup to use encfs and git over a usb drive. Where I have a local unencrypted folder on each computer and the encrypted encfs files are on the usb drive. This seems to work fine. What I am worried about is when the usb drive fails. I basically want to automatically keep a backup of the encrypted files on each computer.

How do I go about doing that?

Ideally, create a backup of the encrypted files when the usb drive is connected, or every minute or hour while the usb drive is connected?

If something better is possible, please let me know.

Can I use something like rsync with a cron job to do this? What I don't need is the advanced features of rsync to create a time-line of backups. I just need a copy of the latest files on the usb drive.

  • Last time I asked something 'how do I' I was torn apart. Let's see how this develops here. – Marki Mar 3 '14 at 20:25

For backing up files between two computers, rysnc is usually the way to go. If the files may be changed on either computer, unison might be a better way to go. You can run either regularly via a cron job or manually when needed (more robust for unison). Of course you will have to set up a password-less ssh login to the target machine first.

If you want to sync to a usb device when it is plugged in, you can always create a udev rule (if that's what your system uses) which runs a script to mount the device and do an rsync every time it is plugged in. If doing this, be sure that it doesn't conflict with any other automatic mounting system that may pick the device up.

To do this you would first find out the udev properties of the device as follows:

udevadm info --name=/path/to/device --query=property

Then you would put a .rules file in /etc/udev/rules.d (depending on system) containing something like this:

 ENV{ID_SERIAL}=="device_id_serial", ACTION=="add", RUN+="/path/to/script"

Where device_id_serial is the ID_SERIAL for your device.

Note this is only a very rough outline of what you can do, I have not tested the above (add may not be the correct action). You can always ask another question on any of the above if you are stuck.


you can do it via rsync.

rsync -avz /path/to/source/ /path/to/dest

-a archive -v verbose increases verbosity -z compres files

Also you can put this command into the cron to be executed every minute.

crontab -e   
 * * * * * rsync -avz /path/to/source/ /path/to/dest

with this you will have only modified files backed up with perserving the permissions, so actualy only will be modified modifeid files.

  • You can't rsync to a device file, you have to mount it and sync to the mounted directory! – Graeme Mar 3 '14 at 20:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.