D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Rsync External USB Drive

 



On 16/12/10 11:16, Gibbs wrote:

I want to sync a load of directories when a specific USB drive is plugged in to an Ubuntu server. How can I run rsync when the drive is plugged in (automatically)? I've looked online but they all seem to be manual methods so I'm hoping that it's possible to trigger commands when things are mounted...

Cheers

Gibbs

Here's how I do it quite successfully for a HP RDX drive with removable cassettes (drives)

in fstab
/dev/sdb1   /media/rdx  ntfs-3g rw,user,noauto,exec 0 0

a script in cron.daily

if mountpoint -q /media/rdx; then
   mount /media/rdx
   rsync -arvz /etc /media/rdx
   rsync -arvz /var/lib/samba /media/rdx
   rsync -arvz /home /media/rdx
   #Lastly, unmount the RDX Drive so it can be ejected
   eject /media/rdx
else
   eject /media/rdx
fi

The idea is that it backs up the data and ejects the removable drive, the user sees the drive is ejected, swaps it over ready for the next backup. There's no backups if the drive is not pushed back in.

I'm sure you can hack this to suit your needs.

Martin

--
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/listfaq