[Tutorial] Time Machine backup system with DietPi

Guides and tutorials for various stuff. Posted by DietPi users.
Post Reply
sarmisak
Posts: 8
Joined: Tue May 05, 2015 7:48 am

[Tutorial] Time Machine backup system with DietPi

Post by sarmisak » Thu Aug 20, 2015 9:58 am

Hi all;

Since I use a Macbook I use Time Machine for my regular backups, but backup is a time and CPU consuming process so I prefer doing it overnight at home. For remote backups Apple has a marvelous Time Capsule system, but it is expensive and it can be reproduced by a simple DietPi server.

First make a regular installation of a DietPi server, then install neccessary tools;

Code: Select all

apt-get install netatalk
In a regular DietPi install we don't have a normal user, we have to create a new user so that we can use it to login to our time machine server. There are some workarounds, but this is far simpler.

Code: Select all

mkdir /home
useradd -s /bin/bash -m -d /home/sarmisak sarmisak
passwd sarmisak
Now we have to tell where time machine should keep our time machine folders. I would recommend using an external disk with an external power supply since it does not rely on the power of the RPi USB, I use a WD Essentials 2 TB disk for this job. After you plugin your disk, at the command prompt using blkid list your available disks;

Code: Select all

[email protected] ~ # blkid
/dev/mmcblk0p1: SEC_TYPE="msdos" LABEL="boot" UUID="CB99-4C7E" TYPE="vfat" 
/dev/mmcblk0p2: UUID="1263ae8d-aaf3-41b6-9ac0-03e7fecb5d6a" TYPE="ext4" 
/dev/sda1: UUID="2a96a3dd-2c08-4cfe-90ee-fbfeabf779ec" TYPE="ext4"
/dev/sda1 is what we are looking for, so let's add it to our /etc/fstab file, copy your UUID from this output and in your /etc/fstab remove these lines;

Code: Select all

#External Drives---------------------------------------------------
# - Try and use only ext4 for USB drives
# - Faster performance than NTFS, espically on RPi v1
/dev/sda1       /mnt/usb_1      ext4    defaults,noatime  0       0
/dev/sda1       /mnt/usb_1      ntfs-3g    defaults       0       0
with;

Code: Select all

#/dev/sda1 // Should be on one line
UUID="2a96a3dd-2c08-4cfe-90ee-fbfeabf779ec"   /mnt/timemachine   ext4   defaults,noatime   0   0
You will have to change your UUID when your disk changes, try not to change it and if you must change your disk you must change the UUID in here, too. I try to use UUIDs instead of /dev/sdaX, because if you plugin more than one disk the locations might change and you can overwrite on other files by fault.

Now, let's create the mount point and give privileges to our user;

Code: Select all

mkdir /mnt/timemachine
chown -R sarmisak:sarmisak /mnt/timemachine
Edit /etc/netatalk/AppleVolumes.default and add this line at the end of the file;

Code: Select all

/mnt/timemachine/           "Time Machine"  options:tm
Let's mount the disk and restart the netatalk server;

Code: Select all

mount -a
service netatalk restart
In your Finder window press Command + K combination, a "Connect to Server" window should appear, in the address line write afp:// and your DietPi IP address;

Code: Select all

afp://192.168.xxx.yyy
It should ask you your username and password, fill in the neccessary fields and connect. You should be able to read and write in your Time Machine folder. Now, let's add this disk to your Time Machine on your Mac. Click Time Machine in your System Preferences. Turn it on and click "Add or Remove Backup Disk..." button. You should be able to see your Time Machine server as "Time Machine" in the list, click and fill in the user information again. If you leave your Macbook connected to a power source, it should backup your computer to this Time Machine system automatically whenever you get connected at your home network.

User avatar
Fourdee
Site Admin
Posts: 2783
Joined: Tue Feb 06, 2007 12:36 pm

Re: [Tutorial] Time Machine backup system with DietPi

Post by Fourdee » Thu Aug 20, 2015 1:25 pm

Hi sarmisak,

Many thanks for posting this guide. I will give it a spin on my RPi when i can.

I've also changed this post to a sticky.
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal and Bitcoin.

Munich77
Posts: 1
Joined: Thu Sep 13, 2018 12:42 pm

Re: [Tutorial] Time Machine backup system with DietPi

Post by Munich77 » Thu Sep 13, 2018 12:45 pm

Thank you for the great tutorial. Can i use Netatalk together with Pi-Hole? Or are there problems here?

User avatar
WarHawk
Posts: 409
Joined: Thu Jul 20, 2017 7:55 am

Re: [Tutorial] Time Machine backup system with DietPi

Post by WarHawk » Fri Sep 14, 2018 4:38 am

Cool howto

Easy way to create user that autocreated directory in /home is

Code: Select all

# adduser user
Quick howto on creating a sudoer user as well
https://www.digitalocean.com/community/ ... quickstart

BAOZHAI
Posts: 3
Joined: Thu Sep 13, 2018 3:43 pm

Re: [Tutorial] Time Machine backup system with DietPi

Post by BAOZHAI » Thu Dec 06, 2018 10:23 am

I was going through this thread and most of the stuff I read were technical in nature hence I thought of putting up my question here. I want a VPN for my macbook and would appreciate if anyone suggests me the right vpn. I also read this article and they have place purevpn on top, should I go with it ?
https://www.vpnranks.com/best-vpn-for-mac/

User avatar
WarHawk
Posts: 409
Joined: Thu Jul 20, 2017 7:55 am

Re: [Tutorial] Time Machine backup system with DietPi

Post by WarHawk » Mon Dec 10, 2018 5:03 am

Great tutorial! Thanks!

Post Reply