I thought I’d write down some notes in case I ever want to come back to this.
Basically I had to do a restore from backup the other day. I had backups but they were a little dated and I wondered if there was a better way that swapping round all my disks to do a local backup.
We’ve got a pretty quick internet connection and I have some connections through work so I can play with things a bit more than most people might be able to.
I was looking at using my Raspberry Pi to act as the file server. I haven’t got around to this yet because I have better things to do than mess around with computers when I’m at home.
But I thought this is still flawed, what I really want is a remote backup and for it to be done with Time Machine, because hey – that works great!
It solves several things for me – any local external usb storage takes up valuable ports, desktop space, opportunities for other things to be stored on the drive… also, if you have a catastrophe – the disks are still on site!
What I like to do is have my work machine and my home machine and have them have backups of eachother’s files.
So here’s a solution, it’s not perfect but it does work.
Take advantage of the magic of SSH tunnels.
OK they are a bit scary on the face of it. But they get you around so many of the restrictions that the big bad scary Internet places on us.
Basically things are pretty much walled off only to work on the local network because it’s known and safe(r), yeah that’s another story but run with me there.
So here’s the magic line:
sudo ssh hostname -l username -L 22:127.0.0.1:548
Basically, take the stuff that goes through port 548 that’s on the ‘hostname’ server and use the localhost port 22 address for it instead.
Port 548 is for AFP/Apple Filing Protocol and is basically what Time Machine likes for doing its stuff on a network.
The Server End
Once you’ve got this round your head, you can set up your file server. I was just testing this out so I fired up an Ubuntu VM and followed this article.
Note in scope here: Being able to access your server from your home network. You need something that’s publically accessible really.
To get it to work on your Mac, make sure your magic SSH tunnel is in place, check you can mount the network drive by pointing at afp://127.0.0.1:22, get your password right etc. Then go into Time Machine preferences and add the disk.
Boom you are done, or you’d think right?
Turns out there’s a little more. Now you are doing something odd, Time Machine doesn’t expect you to be mounting an AFP share through a weird port so when it stores the password to access it in future it doesn’t quite store the correct address to use. So you need to go into Keychain Access and under the System Keychain you’ll see a Time Machine Password, just edit the “Where” field in there to include “:22″ at the end of the URL and when Time Machine next runs it’ll run over the Internet to your share.
Bonus HFS+ Round
Follow steps 2 and 3 on this page to use the drive attached to your VM on a HFS+ partition, that way if you ever have to restore just bring the drive home and it’ll be so much quicker as you can mount the drive locally rather than wait for all those bits to move over the series of tubes.