my rsync fav options

January 30th, 2008 by amatesi

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 GNU Linux, System Administrator | No Comments »

change debian hostname.

January 18th, 2008 by amatesi

I stuck into a little problem related to a hostname change; basically I needed to change hostname for a basic debian install.

I then powered up my fav browser with my fav search engine (FF + Google), then searched for that stuff.

Easy as that! You change Hostname by simply doing

vi /etc/hostname (and put your new hostname inside this file, in place of the old one)

and that’s all. NOT!!!

Now launch

vi /etc/hosts

…and change also the other stuff were you see the old name.

Now you can safely reboot (or simply logoff/logon) to see changes take effect immediately.

Posted in GNU Linux, System Administrator | No Comments »

MS Windows XP, Win2k3 & Vista Password Reset mini-Howto.

January 14th, 2008 by amatesi

Generally, I am used to store my _important_ combo of user/password inside a key+strong password encryption DB file.
The Software I love (and hate) is KeepassX (grab your copy here http://www.keepassx.org/ - XP, Linux or Mac OS X).

Once in a while (especially after holidays…), I may forgive to keep my passwords DB updated, as a result, I may end up struggling to gain access at a damn login screen :-((
…and that’s what just happened recently!

So I was in the search of a free method to reset the MS Windows Local User Account’s Password. The case applied to an install of MS Windows 2003 Server, but it should apply as well as for Windows XP and Windows Vista.
After some Goggleing, I ended up to an interesting method that worked fine (and freely) for me: I downloaded a mini CD with a linux kernel from here: http://home.eunet.no/~pnordahl/ntpasswd/ (thanks pnordahl!), mounted the iso inside the VM and booted it. Then I just followed the on screen info (it’s easy: menu driven), you are presented with a List of functions to choose from, simply by pressing corresponding letters/numbers.

Important Note: This method writes data inside windows registry by using ntfs-3G, a GNU/Linux RW NTFS compatibility layer, believed safe to use (no warranties BTW). Be sure to have Windows NTFS partition (were Windows resides) CLEANLY UMOUNTED, else the program won’t work. Some W2k3 (for security reasons I guess), need to be correctly shutdown from an user logged in; if you shut it down by cold reset or power OFF, you’ll end up with an unclean NTFS.
I’ve read somewere (and suggest hereby) first booting Windows in “Safe Mode” (by pressing F8 before the Boot Up process), then Reboot from there.
Next mount the iso and boot from it. Then you’re ready to reset the User Local Account’s Password !

You could now boot your windows & enjoy.

Posted in MS Windows | No Comments »