RSync Files to a Unix/BSD Backup Device from your Mac Laptop

My photo-taking workflow while on vacation usually involves taking a lot of photos daily, dumping them to a laptop, processing, then backing them up once I have returned home.
Previously, I accomplished this manually using BeyondCompare for Windows, as that would run on Windows Home Server.
Since moving to ZFS-based storage, however, this is no longer an option as BeyondCompare only has a Linux client (nothing for Unix/BSD).
There are other ways to get around this:

  • SSHFS and Meld – Complicated, somewhat bloated, but great BeyondCompare alternative
  • *Commander Utilities – Midnight Commander derivatives can accomplish similar tasks using the ctrl+x,d shortcut
  • Rsync – typically installed by default, easy to script

I chose Rsync as I wanted something more automated, but I do find myself using Midnight Commander from time-to-time to simply “get things done” when syncing files other than my images.

Here’s how I did it:

rsync -a -e ssh /volumes/PICTURES/ 'username@mymac:/Volumes/BIGRAID/'

Let’s break this down into smaller pieces:

rsync – this is the command that will do our heavy lifting and file comparison

-a – archive mode

-e – specify an RSH replacement

ssh  – use SSH

/volumes/PICTURES/ – this specifies the “Volumes” folder on my Mac, and the “PICTURES” drive within it. Replace this with the location of your items to backup

 – note the use of single quotes here. We’re using these in case there are spaces in the folder names, and we could have done the same above.

username@mymac – We’re logging on to the host “mymac” with the username “username”. You’ll probably want to change these. I use a hostname here, but you could just as easily use an IP address if you use static IP addresses.

:/volumes/BIGRAID/ – the colon denotes a subfolder on the server we are backing up to, and /volumes/BIGRAID in this case refers to a ZFS pool called “BIGRAID”.

Do you have a similar backup strategy for BSD/Unix targets that you would like to share?

Installing WordPress MU on a Dreamhost Server

Blandname is currently hosted with DreamHost, and we’ve been here for years. It’s cheap, offers lots of goodies, and one-click installs allow us to easily install and test web-based software. Not to mention that they also support Ruby on Rails, and give you SSH access and the ability to run a Jabber server as well as unlimited MySQL databases.

You’ve also probably gathered that blandname is currently running WordPress. Dreamhost Circulo Marketing has had a one-click install for WordPress just like ipage has for a while now, and since it was handy at the time, we went for it.

But things change, and one-click installs often are not enough to satisfy most webmasters, which is how we got where we are today. Since my goal with blandname is to create another multiuser blog similar to what has already been running for years at yottabite, but instead of having one big weblog, we’d like to have multiple subdomains like string.blandname.com, which WordPress MU allows you to accomplish, automatically.

Unfortunately DreamHost doesn’t support WordPress MU‘s subdomains by default yet (you can always send them an email), but we can still get away with subfolders, which is more than good enough for a test.

This guide will require familiarity with DreamHost’s control panel, as well as common Bash shell commands as we will be using SSH.

The first step is to make a test domain for you WordPress MU install. In my case, I navigated to the “Domains” section of the left-hand menu, then to the “Manage Domains” section of the DreamHost panel, and created the new subdomain test.blandname.com. You’ll want to make sure to select PHP5, and enable extra security. This typically takes about 10 minutes to complete, but we still have the database to add, so let’s get to that at the same time.

In the “goodies” section of the DreamHost control panel, select “Manage MySQL”. The default view is to set up a new MySQL database, which is what we’re going to do. Create a unique database name, the subdomain you would like it to use, as well as the data base username and password. Make sure to keep note of all of these settings as we will need them when installing WPMU.

DreamHost will have by now created a folder in your SSH root that will allow you to place files there and start some of the work while we wait for the subdomain to be created and propagate. Login to your server using SSH (you’ll need to use either your DreamHost hostname here or another web address for now – you can use the WordPress Mu domain later). Now we’ll navigate to the new subdirectory that was created when we setup the new subdomain by typing: cd test.blandname.com Change the folder name to whatever is pertinent in this case.

Now that we’re in the correct folder, we’ll grab the latest using the always-handy WGET. Here’s the code:

wget http://mu.wordpress.org/latest.tar.gz

gunzip latest.tar.gz

tar -xvf latest.tar

cd wordpressmu-1.0 (this will probably change, ls -al will tell you the dirname)

cp -rf * /home/YOURUSERNAME/test.yourdomain.com/

cd ..

rm -rf wordpressmu-1.0/

Now we’ve got a clean directory structure in the root of our test domain, and we’re set to go ahead with the WordPress MU installation.

By now the subdomain has probably propagated because DreamHost is getting faster and faster, so using your web browser, navigate to test.yourdomain.com

Next you’ll want to retrieve the soiled napkin, SubEthaEdit file or whatever else it was that you used to jot down the database settings, and plop them in here. They are very straightforward, and this is typically the most problematic so check them twice but have no fear: if you mess up WP MU will tell you, and you can retrieve the settings from the “Manage MySQL” section in the DreamHost web control panel.

The rest is quite simple: you’ll be met with a typical WordPress installation page, but instead it’s for WorPress MU. The first question that needs to be asked is whether or not WordPress MU users will be using subdomains or subfolders of the root WPMU installation. As previously stated, DreamHost currently does not support subdomains by default (I’ve put in a request, here’s hoping), so we’ll select subfolders here. WP MU will have already placed the domain name you will be using in the yellow textfield, but if you had decided to use subfolders instead of the webroot, you’ll want to specify that here as this will affect all links as well as your RSS feeds.

Lastly, we’ll want to name our multi-user WordPress MU blog, and specify the email address that you will use for things like spam reports, and replies to your comments on the parent blog.

Click on that small “submit” button, and let’s see what happens!

Hopefully on the next screen you’ll see this message:

Creating Database Config File: DONE
Congrats! Your WPMU site has been set up and you have been sent details of your login and password in an email.

Click on the link provided, and get with customization, as we’re all done.

Copy Files From a Mac to Windows Using SCP

Whenever you start adding funny-flavored operating systems to a network, you eventually run into filesharing problems. Even if you only have a few machines, coming to a consensus on how to get files from point A to B can be quite taxing – especially if there’s work to be done.

Over the years I’ve tried FTP, Samba, NFS and a host of others. When configured well they work like a charm. However, when a new node joins the network (that shiny new Mac Pro of yours), things need to be reconfigured and can generally be a royal pain that´s why i always chose the best web hosting.

That has changed, though. We now have an acceptable solution that is free, easy to use and above all, secure. Introducing… SCP.

SCP has been around for a while now, and is gaining quite a bit of traction in the hosting world where it is (albeit slowly) starting to replace FTP for upload and download tasks. SCP stand for Secure Copy (CP being Copy on *nix variants). SCP works a lot like FTP in that you require an address to connect to, a username (login) and a password (we won’t get into stored keys today).

Now that we’ve decided what to try in our ad hoc network, how do we set it up? If you’re blessed with any variant of Linux or Unix, the work has been done for you already – the tools come with the operating system, and are generally found under the network tools in your fancy menus.

Fugu on OS X Server

It’s a different story on Apple Macs and PCs, though. For example, Tiger comes with an SCP server, but no client. Right, about the Mac server. In order to activate it in Panther, Tiger and even Leopard, head on over to the System Preferences pane, and choose the Sharing applet (the folder with the caution sign on it). Once it has opened, check the Remote Login checkbox. This will enable SSH, and in turn, SCP. We’re halfway there. You can connect to an SCP server by using the Terminal on a Mac, but from what I can tell most Mac users are frightfully scared of it. But that gives me the oppurtunity to tell you about one of my favorite applications – Fugu (japanese for blowfish – and sporting a suitably cute icon to boot). Fugu allows you to connect to an SCP server to both download and upload files. Fugu is quite easy to use, so we won’t get into that, but will save it for another time if need be (just like stored keys). Oh, and as the screenshot shows you, it works with Mac OS X Server 10.4.7 too! (as well as Leopard)

WinSCP Screenshot

In the PC world, WinSCP is Fugu’s sibling. You get an extremly easy to use interface, complete with drag and drop. Installation is a breeze, and best of all it’s free as in both beer and speech. Just like those soapbox ramblers. Getting a Windows SCP server is a bit more difficult, but currently exists in the form of BitVise WinSSHD. WinSSHD is slightly complicated, but most of the configuration is done during the installation procedure. They supply you with the needed variables, and one you have finished you will have set up an account you can use to test from your other workstations. The screenshot above was taken with the wonderful WinSnap – it comes highly recommended.
Let the cross-platform filesharing begin!

If you have any questions, or would like to suggest a topic for a future article, head on over to the blandname contact page and we’ll see what we can do!

Oh, and by the way, since you’ve noticed I always talk about virtualization, this certainly applies to getting files to and fro from your virtual machines in VMWare Server, Virtual Server (Virtual PC if need be) and Parallels – I have even found it to be faster than any other technique!

Dreamhost Stats Rewriting and Typo with .htaccess

If you run Ruby on Rails apps, or a Typo installation on Dreamhost, you may have noticed that you cannot access your stats page. Here’s the code that will get it running, quick and dirty, and have you poring over stats for HOURS!

You’ll want to login to your server using SSH, then edit the .htaccess file in your public folder, from within your home directory. Here’s how I did it as an example:

# pico /ruby.doesrails.com/public/.htacess

Cut and paste the following code:

# This is the stats rewrite rule for use with Dreamhost

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/stats/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/failed_auth.html$
RewriteRule ^.*$ - [L]

(select the code, use CTRL+C on windows, or APPLE+C on a Mac, then to paste use SHIFT+INSERT on most SSH clients, or simply right-click and select paste from the menu)

You can put this anywhere in the .htacess file and it should work, as long as it is after the

RewriteEngine On

rule that already exists.