Saturday, December 26, 2009

Changing Your Domain Password When Your PC is not on the Domain

Recently, I had to change my domain password from a desktop wasn't on the domain. The solution I found was to terminal service into a server with my domain account and use Ctrl+Alt+End to bring up the Windows Security menu and select Change Password.

This took me way longer to figure out than I'd like to admit.

Saturday, December 19, 2009

?? Operator Precedence in C#

I've been stung by this a few times in the last month.

The ?? (Null coalescing operator) has a really low precedence in C#. It's well below the arithmetic operators. In fact, it's second from the bottom according to MSDN. For some reason, I expected it to be quite high.

Take this code as an example.

    int? x = 10;
    int? y = 10;

    Console.WriteLine(x ?? y + 1);
Previously, I'd expect this to print 11. It actually prints 10 (since x ?? y + 1 is equivalent to x ?? (y + 1)).

Tuesday, December 15, 2009

Easy Backups with rsync: Part 3 of 3

In this part we'll write a back up script and finish up.

Boot up off your USB flash drive. Now you need to figure out which drives you want to back up and what they are called in /dev. In puppy this is a piece of cake. An icon for each device is displayed at the bottom of the desktop. Clicking on the icon mounts the device as /mnt/<device name> and opens a file explorer on that drive. All you need to do is click through the devices until you find the ones you want.

Now you need to write the rsync script. Here is mine:

backup.sh
---------
rsync -rltDvP /mnt/sda1/Users/Henri/ /mnt/sde1/backups/windows/
rsync -rltDvP /mnt/sdc3/henri/ /mnt/sde1/backups/ubuntu/

I use this to backup the home directories on my Windows and Ubuntu partitions. Before I run this, I ensure that both sda1 and sdc3 are mounted and my backup drive is mounted at sde1.

Note that the trailing slashes on the paths are important. Otherwise the source folder will copied into the destination.

The switches were chosen to make a copy of the source directory recursively(-r), with symlinks copied as symlinks (-l) and modification times preserved(-t). The verbose messages (-v) and progress indicators (-P) are turned on. This is equivalent to the archive (-a) option but without preserving permissions, ownership and file groups. Because I'm backing up onto a NTFS drive, those options don't work correctly. (Ultimately I'll add the --delete flag to delete files in the destination not present in the source.)

Now save the script and you're ready. Once a week follow the steps given the Part 1 and your backups are sorted.

Monday, December 07, 2009

Easy Backups with rsync: Part 2 of 3

In this part I'll give pointer on how to install some version of Linux onto a USB flash drive.

The idea is to be able to boot off the drive and run the backups from there. The set up must have "persistence" i.e. you need to be able to save files to the drive. Not every set up of Linux supports this - some of the Live USB versions are read-only. I use PuppyLinux because it's easy to set up and has quite a pleasant UI. There are many alternatives but most require quite a bit of effort to get working.

Get a smallish USB stick and follow the installation instructions over here.

In the next part, I'll detail how to write the backup script.