Skip to content

Instantly share code, notes, and snippets.

@vookimedlo
Last active October 10, 2022 02:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vookimedlo/c0e05704d3818afb748938d15cb68e26 to your computer and use it in GitHub Desktop.
Save vookimedlo/c0e05704d3818afb748938d15cb68e26 to your computer and use it in GitHub Desktop.
Headless TimeMachine backup solution @ Raspberry 4

Download Image

curl -L https://downloads.raspberrypi.org/raspbian_lite_latest | bsdtar -xvf-
https://downloads.raspberrypi.org/raspios_lite_arm64/images/

Flash Image

https://www.balena.io/etcher/

Enable SSH and disable indexing of mounted /boot

Mount on MAC, and do following.

➜  cd /Volumes/boot
➜  touch ssh
➜  touch .metadata_never_index

Start Raspberry

  1. put SD-Card to the raspberry
  2. plug a network cable
  3. plug external hard-drive
  4. power the raspberry on

Connect over SSH

ssh -l pi 10.10.10.150
The authenticity of host '10.10.10.150 (10.10.10.150)' can't be established.
ECDSA key fingerprint is SHA256:lix2FjdBgB9b81S9g0am4LqU3kGQCXyPuXhAZ4qrOJs.
No matching host key fingerprint found in DNS.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.10.10.150' (ECDSA) to the list of known hosts.
pi@10.10.10.150's password:
Linux raspberrypi 4.19.75-v7l+ #1270 SMP Tue Sep 24 18:51:41 BST 2019 armv7l

Update system

sudo apt-get update && sudo apt-get full-upgrade
sudo reboot

Kernel 64-bit

Add the arm_64bit=1 to the /boot/config.txt.

Initial configuration

sudo raspi-config

External disk for TM backups

Needs to use fdisk first if proper partition is not used.

Create ext4 filesystem.

sudo mkfs.ext4 /dev/sda1
sudo tune2fs -m 1 /dev/sda1

Check for disk UUID.

sudo lsblk -o name,mountpoint,size,uuid
  NAME        MOUNTPOINT  SIZE UUID
  sda                    894.3G ab61ef70-234e-40c6-9ab6-14cc0c2ecdc2
  └─sda1                 894.2G 

Create a mount point

sudo mkdir /srv/tm

Update /etc/fstab

UUID=ab61ef70-234e-40c6-9ab6-14cc0c2ecdc2 /srv/tm	ext4	defaults 0	2

Mount disk

sudo mount /srv/tm/

Create a shared directory

sudo mkdir /srv/tm/shared
sudo chmod 777 /srv/tm/shared

Samba

sudo apt-get install samba

image

/etc/samba/smb.conf

[timemachine]
    comment = Time Machine
    path = /srv/tm/shared
    browseable = yes
    writeable = yes
    create mask = 0600
    directory mask = 0700
    spotlight = no
    vfs objects = catia fruit streams_xattr
    fruit:aapl = yes
    fruit:time machine = yes

Start and enable samba

sudo systemctl start smbd
sudo systemctl enable smbd

Add a new samba user. Be sure that a system account exists for this user.

pdbedit -a -u pi

Disk power management

sudo apt-get install hdparm

Try to set 5 minute standby mode to the attached harddisk.

pi@tm:~ $ sudo hdparm -S 60 /dev/sda

/dev/sda:
 setting standby to 60 (5 minutes)

Update the /etc/rc.local to set the idle mode during the startup.

/sbin/hdparm -S 60 /dev/sda

Update the bootloader and USB FW

pi@tm:~ $ sudo rpi-eeprom-update -a
*** INSTALLING EEPROM UPDATES ***
BOOTLOADER: up-to-date
CURRENT: Tue 10 Sep 10:41:50 UTC 2019 (1568112110)
 LATEST: Tue 10 Sep 10:41:50 UTC 2019 (1568112110)
VL805: update required
CURRENT: 00013701
 LATEST: 000137ab
EEPROM updates pending. Please reboot to apply the update.

Reboot

Restart the raspberry to be sure that all is setup correctly and working upon on system start.

sudo reboot

TimeMachine

On MAC, just instruct TimeMachine to use out raspberry to backup.

sudo tmutil setdestination 'smb://pi:YOUR_PASSWORD@10.100.100.150/timemachine'

First backup speed-up

Before:

sudo sysctl debug.lowpri_throttle_enabled=0

After:

sudo sysctl debug.lowpri_throttle_enabled=1

Guides

https://kirb.me/2018/03/24/using-samba-as-a-time-machine-network-server.html#fnref:bzaffiliate

https://www.samba.org/samba/docs/current/man-html/vfs_fruit.8.html

https://blog.shawjj.com/speed-up-time-machine-backups-by-10x-f6274330dc6f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment