Sunday, January 5, 2014

Raspberry Pi as TimeMachine

Install the 2013-12-20 Wheezy Rasbpian disk image on an SD card. This will probably work fine on later versions, but I'm being overly specific.

You'll probably want to install a new user instead of the usual pi/raspberry user so follow the guide I wrote here: Change the Default Pi User.

Install vim because great Caesar's Ghost I can never get vi to work right.
sudo aptitude install vim
 Change your hostname because you don't need any extra devices on your network called "raspberrypi"
sudo vim /etc/hostname
sudo vim /etc/hosts
I called mine "BackupPi" because I'm so clever and interesting.
Install enough tools to allow your Macs to find your Pi.
sudo aptitude install avahi-daemon netatalk
Restart your Pi so that you know nothing went crazy.
sudo shutdown -r now
Connect a hard drive to the USB port formatted as EXT4. I don't care how it is done, just do it. Mine shows up as /dev/sda1 but yours might be different.
Now mount your drive.
sudo mkdir /media/external
sudo chmod 775 /media/external
sudo chgrp pi /media/external
mount /dev/sda1 /media/external
Test it to make sure you have proper access to it.
touch /media/external/test_touch
Okay, good work. Now make sure it mounts on boot.
sudo vim /etc/fstab
Add an additional line to the configurations.
/dev/sda1      /media/external      ext4      defaults,rw      0      0
Restart your Pi so that you know nothing went crazy and your disk will auto mount.
sudo shutdown -r now
After it comes back hopefully you can see what is in your drive.
ls /media/external
If you don't see what you are hoping for something went wrong. Crap. Sorry.
If you get to see the test_touch file you created before, congratulations. You did it!
Now you need to get your Mac to know that what you created is a good spot to put your backups. Make a copy of the original settings and create a new file.
sudo mv /etc/netatalk/AppleVolumes.default /etc/netatalk/AppleVolumes.original
sudo vim /etc/netatalk/AppleVolumes.default
Put the following in the new file:
:DEFAULT: options:upriv,usedots
/media/external "External Storage" options:tm allow:@pi
Save it and restart. Cross your fingers.
sudo shutdown -r now
Once it restarts You should be able to easily see that there is a machine with shares available on my network with the name you chose previously. Mine is "BackupPi" and it has a shared folder of "External Storage" so now just tell Time Machine to backup to that folder.

No comments:

Post a Comment