PDA

View Full Version : Synchronise a usb disk with your Documents folder


adrian440
April 13th, 2005, 06:25 AM
Here's a one-line script you can use in a custom application launcher on your panel. Paste the following command into the 'command' space. It uses zenity for visual feedback, and assumes your usb stick is already mounted on /media/sda1. The star of the show, of course, is rsync:

rsync -rtvz --stats /media/usbdisk/Documents/ `echo $HOME`/Documents/ | zenity --text-info --width=600 --height=600 --title="Rsync Output"

To have your documents folder synced to usb disk, just swap the source & destination:

rsync -rtvz --stats `echo $HOME`/Documents/ /media/usbdisk/Documents/ | zenity --text-info --width=600 --height=600 --title="Rsync Output"

So that's two launchers you can use to organise your documents, with just one catch. If you delete a file in your documents directory (or a subdirectory thereof), you may find it turn up again there. To solve this, if you delete a file, delete it from both your usb disk and your documents foler.

kuleali
April 13th, 2005, 10:35 AM
Nice!

razaza
April 13th, 2005, 11:05 AM
If you delete a file in your documents directory (or a subdirectory thereof), you may find it turn up again there. To solve this, if you delete a file, delete it from both your usb disk and your documents foler.

Or use the --delete option. From the manpage:

--delete
This tells rsync to delete any files on the receiving side that
aren’t on the sending side. Files that are excluded from
transfer are excluded from being deleted unless you use
--delete-excluded.

This option has no effect if directory recursion is not
selected.

This option can be dangerous if used incorrectly! It is a very
good idea to run first using the dry run option (-n) to see what
files would be deleted to make sure important files aren’t
listed.

If the sending side detects any I/O errors then the deletion of
any files at the destination will be automatically disabled.
This is to prevent temporary filesystem failures (such as NFS
errors) on the sending side causing a massive deletion of files
on the destination. You can override this with the
--ignore-errors option.

z0mbix
June 16th, 2005, 09:00 AM
Or if you wanted to keep both dirs in sync, use unison:

http://www.zombix.org/?page_id=68

pdk001
June 16th, 2005, 12:13 PM
thank you for the tip

guyomarj
October 25th, 2005, 01:05 AM
Excellent... Unison works perfect.

Maybe you could turn this thread (rsync and unison way) into an HOW-TO on the current Breezy "Customization Tips & Tricks" forum.

TuxDaddy
December 18th, 2005, 07:36 AM
i could get this to work at all. my usb drive functions but i dont know what it is mounted as.

guyomarj
December 18th, 2005, 11:20 AM
i could get this to work at all. my usb drive functions but i dont know what it is mounted as.


Look in /media. For me, either on Gnome or KDE, it is mounted as /media/usbdisk