Mario Orlandi's Snippets

20/02/2012

“rsync” usage examples

Filed under: Uncategorized — Tags: , — morlandi @ 09:20

Syncing a list of big files

#!/bin/sh
while [ 1 ]; do
    echo 'Synching started at ' `date` '...'
    rsync -e ssh --progress --partial -avh ./output/ user@remote_host:tmp/vc_archives/output
    echo 'Sleeping 30 secs ...'
    sleep 30
done

Django media syncing

#!/bin/sh
rsync -avz --progress host:/home/tennismodena/tennismodena/tennismodena/media/uploads tennismodena/media/
rsync -avz --progress host:/home/tennismodena/tennismodena/tennismodena/media/gallery tennismodena/media/
rsync -avz --progress host:/home/tennismodena/tennismodena/tennismodena/media/blog    tennismodena/media/
...

27/10/2011

Readynasduo Files restore via rsync

Filed under: Uncategorized — Tags: , — morlandi @ 18:43

Restore da Ubuntu a NAS

Su Ubuntu:

(1) sudo su
(2) apt-get install fuseext2
(3) apt-get install lvm2
(4) modprobe fuse
(5) vgscan
(6) vgchange -ay c
(7) fuseext2 -o ro -o sync_read /dev/c/c /mnt

e successivamente:

rsync --progress -avzh /mnt/brainstorm/ root@192.168.98.3:/c/brainstorm

oppure essendo il locale:

rsync --progress -avWh /mnt/brainstorm/ root@192.168.98.3:/c/brainstorm

Files check

Per verificare le eventuali differenze evitando qualunque modifica,
utilizzare le opzioni:

-c, --checksum: skip based on checksum, not mod-time & size
-n, --dry-run: perform a trial run with no changes made

Esempio:

rsync -rcnv //mnt/brainstorm/main/ root@192.168.98.3:/c/brainstorm/main/

Verifica dei files copiati alternativa ad rsync


find . -type f -print0 | sort -z | xargs -0 md5sum


If you want to use file sizes as a check on the operation of rsync
(not the best check, but it will catch some kinds of errors) you could
do something like this

( cd source ; find . -type f -print0 | sort -z | xargs ls -s ) > /tmp/
source-stuff
( cd target ; find . -type f -print0 | sort -z | xargs ls -s ) > /tmp/
target-stuff
diff /tmp/target-stuff /tmp/source-stuff

you can use something like "md5sum" in place of "ls -s" if you want a
more industrial strength check...

Theme: Silver is the New Black. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.