So, was having troubles with my rsync backup; the destination drive preserves case but is case insensitive (FAT), so things were backing up *every* time. rsync doesn't do case insensitivity, so the easiest solution seemed to be lowercasing everything on the first drive that wasn't code.
rename is missing on OS/X; it has a man page, but no binary. Perl, I'm rusty enough that this turned into a nightmare, and got a script going that worked... if the file/directory doesn't have a space in it. Enter OS/X's Automator.
"Get Specified Finder Items" as the first task, "Get Folder Contents", check "Repeat for each subfolder", and then "Rename Finder Items", "Change Case", "Full Name", "Lower Case". Intuitive, quick, drag and drop, and done. Could have saved a lot of time by trying the Automator first.
OS/X Automator
rsync backups
I'd argue that at least as important as anything you do on a computer is being able to back it up. I've lost quite a lot of work to bit rot, a mistyped rm command or two, and a spilled beverage or two. Those are mistakes that will probably be repeated more than once, so it's time to plan for them.
There are a lot of ways of going about this, with varying levels of work required. I'm not so much afraid of the work, but I only want to do this once. I have an Apple laptop, XP desktop, and one of those NSLU2 slugs, plus some stuff on a remote unix server I wouldn't mind pulling into this.
The solution I'm going with is rsync, a *nix command line utility. Basically, it copies files from place, and either place can be on the local machine or on a remote box. If a file hasn't changed since the last copy, it won't re-copy it. It can copy the files to a remote box across an ssh connection, and to run rsync automatically, it's useful to automatically log into ssh without a password.
rsync is preinstalled on OS/X, "apt-get install rsync" can put it on the slug, and a quick cygwin install puts it on the XP desktop. (cygwin should probably get it's own post. It gives you a linux shell under windows, and is an awesome tool to have around.) If you're using cygwin, you'll probably also want the cygwin UTF-8 layer, which allows non-ASCII characters in filenames without causing rsync grief.
The rsync project page's examples list comes in really handy, especially 'backup to spare disk'. If you're using a FAT filesystem - Windows - the timestamps won't ever match up, it seems, so you'll want to use the --size-only option; if you let rsync decide if something has been updated based on timestamp, FAT filesystems will cause rsync to always copy every file.
Inside of cygwin, I'm using the following options, spelled out for clarity. I don't always use them all, obviously, but the idea's there.
--verbose --recursive --times --links --delete --delete-after --size-only --dry-run --exclude
--verbose: list every file copied and deleted
--times: preserve the modification times
--links: copy symbolic links as symbolic links
--delete: delete extra files from destination when it finds them
--delete-after: delete extra files from destination after it finishes copying successfully
--size-only: only compare by size, not by checksum or by timestamp
--dry-run: do a dry run, and do not change anything on the destination filesystem
--exclude: exclude a file, for example, Apple's .DS_Store files
The NSLU2 Slug
One of the reasons I wanted to start writing something down about my experiences with tech is the Linksys NSLU2, otherwise known as the Slug.
It's about the size of a deck of cards, draws 10w of power from the wall, and has two USB 2.0 ports and one 10/100bT networking jack. As shipped, it shares drives connected to those USB ports as if it were a Windows machine. This isn't bad, but feels a bit thin for the $85 it costs.
Enter the good folks at NSLU2-linux.org. As it turns out, this is a 266 MHz ARM processor with 32 MB of RAM... which is more than enough to run Linux.
Following the directions provided by the amazing Martin Michlmayr, you need a 1 gig or better external flash memory stick, and optionally, an external USB hard drive.
Flash the unsupported installer image onto the slug. SSH into the box. Install the five packages Michlmayr mentions. You now have a running version of Debian Linux up and running. This takes between an an hour and an afternoon, and should be doable with minimal admin skills.
So, there were a few updates worth making to the slug right away. Opening the case and using this simple hardware kludge to overclock the box from 133 to 266 MHz was trivial, only took a pair of fingernail clippers or an exacto knife, and doubled the speed of every other step.
It's worth looking at are the additional instructions on reducing Debian's memory usage.
If you installed to a flash drive and not a hard disk, you can look into ways to reduce the drive usage. Especially worthwhile is moving the swap partition off of the flash drive, and onto an external hard drive, if possible. Basically, flash media only gets a limited number of writes, and after that, that sector of the drive is permanently dead. Since swap space may be written to many, many times, it's the prime candidate for burning out the flash media.
Additionally, there are ways to make the box automatically upgrade itself every night.
As a side note, if your connections regularly die, the slug includes a small magnet that wraps around the Ethernet cable, to cut down interference. I'm assuming the size of the slug prevents them from building this into the unit. That said, without this magnet, my connections died fairly regularly. With this magnet, connections are stable for days.
I should have started with the most important detail, though. Why would you want Linux on this piece of hardware?
- My slug at home still runs as a drive server, but it can now use USB hubs to have more than two drives connected.
- Instead of just having Windows file sharing (Samba), it also supports AFS (Apple) and NFS (Unix/Linux).
- MT-DAAPD, which lets other computers in the house running iTunes see the slug as if it were running iTunes as well, and shares out the music on the external drive.
- rTorrent, a full-feature text-based Bittorrent client. Here's a link on autostarting it, and how to add an script to Linux to run on boot.
- OpenVPN, to allow VPN networking from anywhere back to my house. Including securely tunneling traffic from an iPhone over unsecured wireless networks.
- SSH tunnel endpoint, securely transmitting my chat and web requests from my public desk at work to my relatively private connection at home. Browsers and chat clients support this pretty easily as a SOCKSv4 proxy.
- DynDNS client, in order to report back it's public IP address to my DNS server, so that I can access it by name from anywhere.
- Apache, to serve static webpages (and MT-DAAPD).
- It doesn't have enough power to run a database application well.
- Due to that, it doesn't work as a dynamic webserver.
- It won't even run Ruby on Rails with SQLite, actually. It's tiny.
- It didn't support a Squeezebox server.
- MT-DAAPD (above) will choke if you give it too large of an MP3 library.
All in all, A+. I've actually bought a second one to leave at another location, for when my home connection is down.
