'

my rsync fav options

January 30th, 2008 by Andrea Matesi 755 Views

Today I'll post my rsync fav options; rsync is a lil program that automates syncronization between two folders, FS or partitions, even remotely by using ssh credentials (better used with keys...). Its main use is to move every kind of data inside the network, keeping it synchronized. That mean that he check all the files that are on one side and confront them withe the files that are on the other side, transferring efficiently only the stuff that change! Every standard Linux System Administrator should know it (man rsync), but I understand there is too much options. At its basic it is used so: rsync $SOURCE $DESTINATION were $SOURCE and $DESTINATION can be a local folder or a remote folder accessed via ssh (ex.: andy@192.168.1.1:/home/andy/backup) But if you tweak it a bit you can gain some more functions/performance. I usually play with it through bash scripts but occasionally I use it directly from the console. When I use it from console, I need to remember the various settings I like, that I'm gonna share here for convenience. Generally, for a basic rsync between two places, and with no deletion, I use this: rsync -aHvzh --progress SRC DST -a is synonym to using -rlptgoD, "a" does stand for archive; the included "a" options will be analized next. -H stand for preservation of Hard Links (a synonymous name for an inode, ex. "DATA" is the real, meaningful, data and A.txt and B.txt is a pointer to that data). -v is for verbose; I like talkative programs. -z is for gzip compression during transfer (not where it puts the files, it is real time) -- Best with powerful processors. -h is for human readable sizes (in place of telling me: "transfered 10737418240 bytes", he would say: "Hey mate, your 10Gb it's already there!"). --progress does show progress in real time with ASCII gfx. Now let's check what does -rlptgoD mean (they are simpler...): -r is for recursive, essentially I need this to move entire directories, not only files. -l keeps the symbolic links so. -p keeps the same file permissions on the receiving side (r,w & x). -t keeps the same date and time modification (better keep it for efficiency purposes, rsync this way know if the file changed or else). -g similar as g, keep the same group on the receiving side. -o similar as o, keep the same owner (the user) on the receiving side. -D mean that it preserves character devices and block devices (ls /dev to see what these are) on the receiving side. A very useful option I used in the past was -n -n does stand for DRY RUN, it means that you are still not sure about wich option to use, and wanna still just try and experiment with the thousand options how the transfer will be, but without making it happen for real...very useful! Then there are the various --delete-when? They are useful when you are sure that the transfer is ONE WAY (if not sure, don't use it!) only. You can use: --delete-before --delete-after & --delere-during Wich all do DELETE the transfered files at the specified time. Then we have the exclude-from=files, a good option that allow rsync NOT to transfer the specified directories & files following the "=". After the "=" can be used also a file containing all the files/dirs not needed during the transfer (say /sys, /dev, /tmp & all). Example: Let's say I do not want to transfer the following folders: tmp, dev, proc, sys, floppy, cdrom, rsync, mnt, media ; I create a file wich contain, for every line, the name of a folder I don't need: echo -e "/tmp\n/dev\n/proc\n/sys\n/floppy\n/cdrom\n/rsync\n/mnt\n/media\n" > /tmp/excluded.txt ...then I recall my rsync with the option exclude-from=/tmp/excluded.txt and the joke is done!

Posted in LINUX, System Administration | Comments Off on my rsync fav options

Comments are closed.