Ye Olde iPhone Backup Server

Toolboth Tavern 04 by Shadowgate, on FlickrDo you have an old smart phone, tablet, or computer in a drawer or a closet somewhere that you never got around to selling or giving away? You might consider setting it up as a development server as Jason describes here. You can also set it up to act as an extra layer in your backup strategy.

This is what I decided to do with an old iPhone 3GS that still worked, except a testy headphone connection, that had a nice 32GB of space on it. I wanted an extra place to backup my mail and dump larger files quickly for transfer to other devices that might connect to my local network (including guests who visit). While I won’t go into all the steps in complete detail, here is basically what was required to get this up and running (I’m writing here from perspective of using an iPhone and connecting to it from other OS X devices):

  1. If you have an iPhone or iPad (rather than an Android or other mobile operating system) you will need to first Jailbreak it in order to allow it to perform its new duties. Amy Cavender and Ethan Watrall have written more about what that means here at ProfHacker here and here. Depending on your version of iOS and which device you have, this may take a little googling about how to download the necessary software and perform the jailbreak.
  2. Once your device is jailbroken, you will likely have to install one of the standard “Networking” packages in Cydia called “OpenSSH.”
  3. Plug your old device in and leave it somewhere with a good connection to your local home network.
  4. Find out the IP address of your device. You will use this to connect to your device and copy files. On the iPhone or iPad go into “Settings > wifi > your connection” and look under the IP address listed there.
  5. Now you should be able to connect to your device with SSH or SFTP. Use an FTP application (such as cross-platform FileZilla, or Fetch and CyberDuck on OS X), configure it to use SFTP, and connect to your device with the IP address you took note of. Your main user on the iPhone should be the “root” account so use that for username (any tips out there for best way of creating new users on a jailbroken iPhone to use instead?) and the default password is “alpine.” This absolutely must be changed to stand any chance at security. To change it, connect via SSH connect to the phone and change the password of root to something else. You may wish to look into further ways to restrict access to the machine to only other computers on the local network.

Optional: If you know you will be connecting a lot to your backup server from various applications, it can be annoying to remember the IP address. You can call it something else by modifying a kind of a personal phone book called your “hosts” file. Editing this file you can, for example, change the less than memorable 10.0.1.16 to something like “oldman.” Then, when you connect to it, you need only enter the latter into the server address.

Bonus: In OS X can also connect to your phone directly from the Finder if you install one of various packages for jailbroken phones that enable connections through “AFP.”

For More Seasoned Hackers: Get lighthttpd or Apache web server up and running on your iPhone to use it as a kind of home network home page, serving information to your guests about their home or a standard set of files (“house-FAQ.pdf” or “guide-to-getting-shower-temperature-just-right.pdf” anyone?). Or, get standard development tools and languages running on the iPhone. As with hosting any web servers or servers on a local machine, this comes with additional security risks so be sure to keep this in mind and learn about how you can restrict access and “harden” your installations.

Gold Hacker Medal: Replace iOS completely with Linux and give your iPhone a new life.

Has anyone else found useful things to do with old smartphones and tablets they have?

Creative Commons licensed photo by Shadowgate

Setting up a Local Folder Backup Sync On Your Mac

folder by Tim Morgan, on Flickr Hopefully most our readers here have a good backup routine in place. After learning the lesson the hard way, I now I use an obsessive combination of a cloud-based system (I use SpiderOak, which we introduced here and here), time machine, the mirroring of important files between two computers with the help of SpiderOak, regular backups to a hard drive and more irregular backups to a medium-term storage medium. This, in turn, is deposited at a safe location in a country not likely to be destroyed in a nuclear apocalypse at the same time as the country I live in.

One common task needed for this variety of backup procedures is the syncing of a folder, especially when I back up to my external hard drive. I have tried lots of different folder syncing apps over the years, many of which can now be found on the App Store, but I’ve noticed that, since the coming of OS X, some leading sync apps (such as Carbon Copy Cloner) are running a simple open source command line utility to perform their task behind the scenes. Today I want to introduce one of these that I have recently started using: rsync. Rsync has been around since the late 1990s as a way to synchronize folders from the command line (Read Lincoln’s introduction here) of Unix and Mac OS X. If you use a Mac, rsync should be already installed.* When used for uni-directional sync (I won’t cover bi-directional sync here), it copies folders and files from a source location to a destination, and optionally can remove files that no longer exist at the source from the destination.

Please use this at your own risk. Try it first on a test file or folder first, for example, so you see what it does.

To keep a collection of my primary sources synced with a folder on my backup drive I open up my Terminal application in the Applications->Utilities folder and enter:

rsync -a -v --delete /Source/BackMeUp/ /Volumes/BackupDrive/BackMeUp

Tip: Drag a folder from the Finder and drop it onto the Terminal to find a folder path easily but add the trailing “/” in the source.

Why is this better than simply dragging the folder in the Finder to the destination location on my backup drive? Well, using a command like rsync only copies the things I need over (new or modified files), and only deletes the files I no longer need. It can change a 20 minute copy-and-replace operation into a 2 minute one if you have many gigabytes of files that have only a few files that need updating.

Let me explain the command in a bit more detail. You can read this yourself in the manual for the command if you type “man rsync” at the command line, but briefly, “-a” is “archive mode” which is explained in this great MacLife overview of rsync found here. It preserves timestamps and permissions on your files. The “-v” option increases the verbosity of the command. I like to know more about what is going on when the command is run. The “–delete” command, which looks frightening, is used to delete files in the destination folder that no longer exist in the source. If you change the name of a file in the source folder and run the command without –delete, for example, you will get both a file with the old name and the new name in the destination folder, and any files you have deleted will remain as ghosts in the backup destination folder.

Now, obviously, I am in no mood to type this command every time I want to perform my backup. Hackers among you who spend a fair bit of time on the command line may want, at this point, to add an alias for this backup routine to the .bash_profile file that lives in your home folder or schedule a regular backup using launchd or cron. However, for those of you who don’t spend much time hanging out in your Terminal, you can easily save your backup routine by creating an Automator application:

1) Open the “Automator” in your Applications folder
2) Create a new “Application”
3) In the search bar on the left find “Run Shell Script” and drag-and-drop this into the blank pane on the right.
4) In the text box for the code (it may say “cat” as an example, delete that text) enter the rsync command you used for your backup (Again! Please use with care and test it in the command line with a test folder so you see what the command does)
5) I like to see the output of the command, so I drag-and-drop another “New TextEdit Document” command under the “Run Shell Script” command so that the output of rsync will get dumped into an empty text file, that opens upon completion of the sync.

Save this application and then you simply run it every time you want to perform your backup from that particular source folder to a destination (which can be an external drive).

Have you ever used a command line sync utility like rsync or ditto? Are there other free or commercial folder sync applications you like?

* I believe Mountain Lion comes with the outdated version 2.6.9. I have seen notes here and there that the newer 3.0.x versions are better at capturing some file attributes (see here, for example) and resource forks on old pre-OS X files. I haven’t experienced any problems without making this update, but if anyone understands this better, please share.

Folder Image:
Creative Commons Attribution 2.0 Generic License  by  Tim Morgan