Use rPi as a Time Capsule - another method


41 posts   Page 1 of 2   1, 2
by danb35 » Thu Jun 13, 2013 9:39 pm
I've looked at a number of guides on how to use your rPi as a Time Capsule to back up your Mac using Time Machine, but all that I've seen involve installing quite a bit of software that really isn't needed, compiling software from source, and a bunch of other things that just aren't really necessary. Here's another method that only requires manual installation of two software packages (and one of them isn't really required, if you're familiar with fdisk under Linux).

One thing I noticed about the other guides is that they call for installing HFS+ support on the rPi. The advantage of doing this is that you can partition and format your backup drive on your Mac, so you don't have to mess with doing that under Linux. However, the drive is going to be shared over your network, so it doesn't matter what its filesystem is. I felt it would be better to use a native Linux filesystem, since the drive is going to be connected to a Linux machine (the rPi). I'm assuming that you're starting with a clean installation of Raspbian, configured for your network as desired.

Power down your Pi, connect your storage drive, and boot your Pi back up.

To start, update your installed software, and install Netatalk (the Apple file sharing service) and Gparted (the disk partitioning tool we'll use):
Code: Select all
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install netatalk gparted


Start up the graphical desktop on your Pi using startx, and run gparted (it's under "preferences" in your start menu). Select your storage drive (not your SD card), delete any existing partitions, and create a new single partition of type ext4. Then exit gparted.

You'll now need to set your Pi to connect to your storage drive when you boot, and create a place in your Pi's filesystem for it to go:
Code: Select all
$ sudo mkdir /mnt/TimeMachine
$ sudo chmod 777 /mnt/TimeMachine
$ sudo echo "/dev/sda1 /mnt/TimeMachine ext4 defaults 0 2" >> /etc/fstab
$ sudo mount /dev/sda1


I'm assuming that your USB hard drive comes up as /dev/sda, which it should if it's the only attached USB storage device. If your drive comes up as something different, that will be indicated when you do the partitioning in gparted; you'll want to substitute the correct device above. At this point, your drive should be partitioned, formatted, and mounted into the /mnt/TimeMachine directory on your Pi. All that's left is to configure netatalk to share that directory on the network:

Code: Select all
$ sudo echo "/mnt/TimeMachine \"Time Machine\" options:tm" >> /etc/netatalk/AppleVolumes.default
$ sudo service netatalk restart


You're done with the Pi! Now all you need to do is tell your Mac to back up there. Open your Time Machine preferences, click Select Disk, and choose Time Machine on raspberrypi. Your Mac will ask you for a username and password; give a valid combination on the Pi (pi and raspberry, respectively, by default). In a couple of minutes, it will start backing up over the network.

Let me know if you have any questions on this--it's working fine for me, and seems simpler to me than the other guides I've seen.
Posts: 27
Joined: Thu Feb 07, 2013 6:00 pm
by thebertozz » Tue Jun 25, 2013 4:24 pm
Hi! Thanks for the guide, i followed it step by step but i can't get time machine working... i have samba protocol working on my Pi and i see it as a server from my mac, is there something to see if netatalk is working?
When i click on "select disk" the only option i have is to search for time capsules, i've tried that but it says it can't find anything on my network.

My Pi is connected via ethernet to the router, which has an access point connected for wi fi networking.

Thank you
Posts: 4
Joined: Tue Jun 25, 2013 4:14 pm
by thebertozz » Tue Jun 25, 2013 5:13 pm
Ok i solved my problem, i didn't connect my Pi to my mac!

I just clicked on finder, on the menu bar on go.. and then on connect to server, i put afp://mypiip and then i clicked connect, now it works!

Thanks again for the guide :D
Posts: 4
Joined: Tue Jun 25, 2013 4:14 pm
by texaspi » Tue Jul 30, 2013 9:25 pm
I'm running into a problem, maybe someone can help me out.

When I run:
Code: Select all
sudo echo /dev/sda1 /mnt/TimeMachine ext4 defaults 0 2 >> /etc/fstab

I get the following error:
Code: Select all
bash: /etc/fstab: Permission denied


Any thoughts on a fix?
Posts: 2
Joined: Tue Jul 30, 2013 5:32 am
by thebertozz » Tue Jul 30, 2013 10:14 pm
I had that problem too, just type sudo nano /etc/fstab and add manually /dev/sda1 /mnt/TimeMachine ext4 defaults 0 2 as the last line in the file ;)

If the system doesn't permit you to save fstab file, type sudo chmod 744 /etc/fstab or even 777 (because the user of the file should be root), make the change, save the file with ctrl and O, then re-change fstab permissions with sudo chmod 644 /etc/fstab

If you use >>, it means that the things you write before the operator are outputted in the file or whatever you write after the operator, but sometimes it doesn't work like in this case :?

Hope it helps!
Posts: 4
Joined: Tue Jun 25, 2013 4:14 pm
by lynski » Thu Aug 01, 2013 11:34 pm
Hi there

When i connect to time machine via my macbook after i type in user and password it says "You do not have the necessary read, write and append privileges on the selected network backup disk." I am using pi and raspberry as the username and password. Anybody got any ideas?

Thanks in advance

Joel-Lynski
Posts: 2
Joined: Thu Aug 01, 2013 11:29 pm
by texaspi » Fri Aug 02, 2013 4:00 am
Thank you for your help! No I'm getting the same permission denied on the following command:
Code: Select all
sudo echo "/mnt/TimeMachine \"Time Machine\" options:tm" >> /etc/netatalk/AppleVolumes.default


thebertozz wrote:I had that problem too, just type sudo nano /etc/fstab and add manually /dev/sda1 /mnt/TimeMachine ext4 defaults 0 2 as the last line in the file ;)

If the system doesn't permit you to save fstab file, type sudo chmod 744 /etc/fstab or even 777 (because the user of the file should be root), make the change, save the file with ctrl and O, then re-change fstab permissions with sudo chmod 644 /etc/fstab

If you use >>, it means that the things you write before the operator are outputted in the file or whatever you write after the operator, but sometimes it doesn't work like in this case :?

Hope it helps!
Posts: 2
Joined: Tue Jul 30, 2013 5:32 am
by thebertozz » Mon Aug 05, 2013 4:12 pm
texaspi wrote:Thank you for your help! No I'm getting the same permission denied on the following command:
Code: Select all
sudo echo "/mnt/TimeMachine \"Time Machine\" options:tm" >> /etc/netatalk/AppleVolumes.default

[/quote]

As you can see, you're using the same command as before (echo) and the same operator >>, that means that you're trying to write /mnt/TimeMachine \"Time Machine\" options:tm in the file placed in /etc/netatalk/, called AppleVolumes.default.
If you don't have write permissions on that file too, you can copy the procedure that i explained in the other post, it should look like this:

Code: Select all
sudo chmod 777 /etc/netatalk/AppleVolumes.default
sudo nano /etc/netatalk/AppleVolumes.default


Now write on the file /mnt/TimeMachine \"Time Machine\" options:tm
Save it, and then
Code: Select all
sudo chmod 644 /etc/netatalk/AppleVolumes.default
Posts: 4
Joined: Tue Jun 25, 2013 4:14 pm
by mszymans » Thu Aug 15, 2013 2:30 pm
The 'chmod' step needs to come after the 'mount' step or you likely have permission problems.
Posts: 1
Joined: Thu Aug 15, 2013 2:26 pm
by danb35 » Tue Aug 27, 2013 2:46 pm
thebertozz wrote:Now write on the file /mnt/TimeMachine \"Time Machine\" options:tm

...and since you're not doing that at the command line, you don't need the backslashes in that line. I'm not sure why there are permission issues when using sudo--"root, God, what is difference?"

That said, I'm having occasional problems on my Mac where it won't run the backup even though the netatalk services are running. Restarting them fixes the problem temporarily. I haven't had an opportunity to track it down yet.
Posts: 27
Joined: Thu Feb 07, 2013 6:00 pm
by Enderend » Fri Sep 20, 2013 8:55 pm
Joel,

I also get the error "You do not have the necessary read, write and append privileges on the selected network backup disk."

Did you ever solve it?
Posts: 1
Joined: Fri Sep 20, 2013 8:51 pm
by skoal74 » Thu Sep 26, 2013 1:44 am
Enderend,

Had same issue. Solved by as noted by mszymans by executing the following AFTER the mounting /dev/sda1.

Code: Select all
$ sudo chmod 777 /mnt/TimeMachine
Posts: 3
Joined: Tue Aug 07, 2012 2:08 pm
by Iainkruger » Sun Dec 01, 2013 12:16 pm
I know this is old but I hope someone can help me. I followed all the steps and I can see the drive on my mac but it does not show up as a drive that I can use when I try to select a drive from the time machine options.
Posts: 2
Joined: Fri Nov 29, 2013 12:04 pm
by andrewr » Tue Dec 24, 2013 4:34 pm
Excellent guide, Thanks! I wrote about the setup process here http://lanjanitor.blogspot.com/2013/12/time-machine-on-raspberry-pi.html The only real difference is I created 2 partitions, one for TM and another for general data. I had to install xquartz for gparted xwindow session.
Posts: 4
Joined: Sat Dec 21, 2013 4:48 pm
by andrewr » Tue Mar 18, 2014 4:06 am
This was working nicely but then every 2-3 weeks I started to get this Time Machine error:

"Time Machine completed a verification of your backups on "raspberrypi". To improve reliability, Time Machine must create a new backup for you."

Options are: back up later or start new backup

I haven't had time to research it but thought I'd post it here in case anyone else is experiencing the same. I'm running macosx 10.9.1 and my timemachine is on a usb harddrive 2TB
Posts: 4
Joined: Sat Dec 21, 2013 4:48 pm
by Dino_Bergomi » Fri Apr 04, 2014 8:27 am
Hello everyone,

Thanks for the excellent post!

I love the idea of having a raspberry Pi working as Time Machine.

I'm sorry if what I am going to ask looks dumb… I am not really that computer-savy, even though with some effort, I end up managing to do what I want.

1st: Is it required that the Raspberry Pi Time Capsule is in the same local network (LAN or Wireless) as the laptop you want to backup from?
I'm asking because I travel quite a lot, and for me the best would be to have the Raspberry Pi at my parents place, where it is safe, and have my laptop (slowly) backup to there whenever I'm online. Time is not really an issue, I would say, because the process could be going for several days. This would be just a safety measure, in case something bad happens to the laptop, where I have most of my work.

2nd: If not possible using Time Machine, would it work as a NAS server?

Thanks for your comments guys!
Best regards,
Bruno
Posts: 1
Joined: Fri Apr 04, 2014 8:16 am
by danb35 » Mon Apr 07, 2014 3:10 pm
The Time Capsule (whether on an rPi, a true Apple unit, or some other server) needs to be network-accessible by your Mac for the backup to run. The easiest way to do that is if they're on the same LAN. If you're in a remote location and can VPN in to your home LAN, that would work as well--though the amount of data being transferred may make this undesirable.
Posts: 27
Joined: Thu Feb 07, 2013 6:00 pm
by jbothma » Sun Apr 13, 2014 8:27 pm
I couldn't see the disk without mounting it so I added this line to afpd.conf

Code: Select all
"Bobdave" -uamlist uams_dhx2.so -port 12000


After a minute or so the drive popped up in the list of available. I then had to give the username and password of a user on the server.
Posts: 1
Joined: Sun Apr 13, 2014 8:22 pm
by andrewgdotcom » Wed May 07, 2014 8:43 pm
The reason the following doesn't work:

Code: Select all
sudo echo foo >> /etc/fstab


is because only "echo foo" is passed to sudo, therefore only "echo foo" is run as root. The >> is always run as yourself.

To perform a redirection as root, you need to parse it in a subshell:

Code: Select all
sudo bash -c 'echo foo >> /etc/fstab'
Posts: 1
Joined: Wed May 07, 2014 7:45 pm
by Dag Rende » Sat Jul 19, 2014 2:57 pm
Great instruction - and simple!

Worked fine for me until I got 'Time Machine couldn't complete the backup to "raspberrypi". The backup disk image "/Volumes/Time Machine/My Macbook pro.sparsebundle" is already in use'.

First time I fixed it by rebooting my raspberry. But second time I had to "Open Time Machine Preferences.../Select Disk.../" click on my disk under Backup Disks and click "Remove Disk". I clicked Select Disk again and selected the disk I just removed. Next backup worked fine again and added to the backups I had before this problem.

This saved me the cost of buying an Apple Time Capsule, and increased my admiration of the Raspberry wonder even more!
Posts: 1
Joined: Sat Jul 19, 2014 2:41 pm
by sebtastik » Wed Jul 23, 2014 1:12 pm
My raspi is running headless, and the HDD I use for Time Machine (working great BTW thanks to this guide) is partitioned and is also used as general storage and will not be plugged in 24/7.

I built a box for my RaspberryPi from my good old Legos which incorporates 5 buttons, 2 LEDs and a breadboard connected on GPIO. Looking and working great!
I'm going to program some scripts to these buttons to turn off Netatalk and easily and safely unmount and eject the HDD to use it for other stuff - and to plug it in and turn everything on again when I'm done with it.
There are going to be buttons for restarting and rebooting as well.
All more complicated or configuration tasks requiring Keyboard and screen are done via SSH or VNC.
LEDs are to show status of running programs.

My problem for now is that turning on the Raspi without the HDD plugged in causes warnings and a root shell opens up interrupting regular boot requiring a CTRL-D to continue how can I avoid/suppress this? I understand that I somehow need to change the way my /dev/sda2 partition in mounted to /mnt/TimeMachine on startup, but don't really know how to edit these settings, thanks in advance
Raspberry Pi model B
PiHub
Macbook Pro (with 13" Retina Display, late 2013) 8GB RAM, 256GB SSD
Posts: 1
Joined: Fri Dec 20, 2013 2:50 pm
Location: Ancona, Italy
by brodtho » Sat Aug 16, 2014 12:00 am
Got this working very well on Mavericks, issue free the whole way, using HFS+ too. Thought I'd give the Yosemite devbook a crack at it and it failed at recognising the drive format but after allowing Unsupported Network Volumes backup was flawless, been backing it up a couple times a day for about a week without issues. Note this must be lost in translation as the drive was formatted HFS+ from a mac, probably be sorted by it's release.

To allow unsupported drives, bash this:

defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1

Note that this has nothing to do with the protocol, still need to use afp, so no samba :(
Explorer of the seven OSI Layers
User avatar
Posts: 15
Joined: Sat Jan 04, 2014 7:12 am
Location: Melbourne, Au
by xXAzazelXx » Sun Aug 17, 2014 1:40 am
How CPU intensive is this?

My raspberry Pi is running few things already, so i am wondering if there will be any performance issues.
Posts: 119
Joined: Tue Sep 18, 2012 8:32 am
Location: Australia
by lanwarrior » Sun Sep 07, 2014 5:36 am
I have the same problem as @sebtastik:

My problem for now is that turning on the Raspi without the HDD plugged in causes warnings and a root shell opens up interrupting regular boot requiring a CTRL-D to continue


This requires my Pi to be connected to a monitor and keyboard all the time so I have to do CTRL-D just for this. Any way to fix this?

The 2nd question: How do I make this into a multi-users Time Capsule? It works for one user, but if another user need to use the drive for their own data that is separate than mine, what is the syntax I need to change?

The 3rd question: The "Encryption" option is selectable, but when I select it, I got this error:
"You do not have the necessary read, write and append privileges on the selected network backup disk". I created a user (say "timecapsule") and gave the permission to own the backup folder (/mnt/usbdrive/mytimecapsule). I use that user when Time Machine asked for username and password. Anything that I am missing here?
Posts: 41
Joined: Fri Aug 22, 2014 6:05 am
Location: Somewhere in the you-es-a
by FM81 » Sun Sep 07, 2014 12:13 pm
To point one: I assume you have an entry in '/etc/fstab' for the harddisk, and if it is missing you'll get the behaviour you've described ...
It's easy to fix, add the option 'nofail' to the line in '/etc/fstab'; for example before:
Code: Select all
/dev/sda1 /mnt/TimeMachine ext4 defaults 0 2
and after changing:
Code: Select all
/dev/sda1 /mnt/TimeMachine ext4 nofail,defaults 0 2


Points 2 and 3 are a little bit "to much Apple-related" for me, so no comment here ...

MfG, FM_81
A: What does the command 'cat /dev/urandom', can you tell me please?
B: Yeah, that's very simple: It feeds your cat with radioactive material!
Posts: 399
Joined: Wed Apr 17, 2013 4:33 pm