I currently have a beagleboard running as a security camera (link to tutorial) and have mounted a remote Samba share locally. I would like the Beagleboard to copy the security footage every 2 minutes to the server and in a separate step I'll then delete files over a certain age.
This way the Beagleboard's SD card will not get full and I'll have a secure, backed up server holding the footage.
There are several ways to set up rsync.
You can have a client/server approach, or if the remote share is mounted locally, then rsync can be invoked locally and will be fooled into backing up off site.
For example my source directory is /home/dingo/camera, my locally mounted remote directory is /media/NAS_mount_point/camera
Normally rsync will not use delta-transfer for what it thinks are local file copies (ie when copying locally it is akin to using cp and it will copy all the wholes in whole). It will still only copy changed files though.
Further, copying to a Samba share generally does not allow rsync to keep the timestamps or permissions. Basic rsync commands will generate errors unless this is addressed.
The following command address this:
sudo rsync --no-W -rLzvv /home/dingo/camera/ /media/NAS_mount_point/camera/
In order, the options: will force using the delta-transfer, recurse into subdirectories, follow sym-links and copy what they point to, use compression and use verbosity level 2.
For a full list of the options available type:
Cron is a daemon which can run other tasks periodically.
Here we will use it to run the above rsync command every five minutes.
We want to run the command as root. Edit the /etc/crontab file with the following command:
sudo nano /etc/crontab
In this file you need to add the following:
*/2 * * * * root rsync --no-W -rLzvv /home/dingo/camera/ /media/NAS_mount_point/camera
This line runs the specified rsync command every 2 minutes as root.
For a full explanation see http://en.wikipedia.org/wiki/Cron or type man crontab at the prompt.