View on GitHub

presentations

Presentation notes from JMU Unix Users Group meetings

Homelabbing - Storage & Backups


Recap: What is homelabbing?


Resources


Storage Issues


Hardware


RAID


ZFS (Zettabyte File System)


BTRFS


Common Terminology


DIY vs Managed ZFS: TrueNAS

TrueNAS Dashboard


DIY vs Managed ZFS: Cockpit (45Drives plugin)

![width:700px](/presentations/homelab-storage/cockpit.png)

DIY vs Managed ZFS: Manual


Creating a ZPool

sudo apt install zfsutils-linux
ls -l /dev/disk/by-id/
sudo zpool create \
  -o ashift=12 \        # for modern 4KB sector drives. should be 13 for 8K sectors
  -O compression=lz4 \  # or zstd, off, gzip
  -O atime=off \        # performance/drive health
  tank raidz1 \         # pool name and zfs config
  /dev/disk/by-id/ata-DRIVE1_______ \ # list which drives make up the pool
  /dev/disk/by-id/ata-DRIVE2_______ \
  /dev/disk/by-id/ata-DRIVE3_______
zpool status

Creating a Dataset

sudo zfs create tank/backups
# optionally, change metadata:
sudo zfs set compression=zstd tank/backups
zfs list

Maintenance

# find the degraded drive (may just be a numeric ID if its really dead):
zpool status
# take the drive offline for the "tank" pool:
zpool offline tank ata-OLDDRIVE...
# find the ID of the new disk:
ls -l /dev/disk/by-id/
# replace the disk:
zpool replace tank ata-OLDDRIVE /dev/disk/by-id/ata-NEWDRIVE

ZFS Zed


Backups


RAID IS NOT A BACKUP


3-2-1 Backups


ZFS Snapshots vs Backups


ZFS Send/Receive

zfs send tank/data@snapshot50 | ssh user@machine zfs recv tank/backup

BorgBackup


Setting Up Borg

# SERVER:
sudo apt install borgbackup

# create borg user and adjust permissions (assumes /tank/backups exists)
sudo adduser borg
mkdir -p /tank/backups/reponame
sudo chmod 700 /tank/backups
sudo chown -R borg:borg /tank/backups
# HOST MACHINE:
sudo apt install borgbackup
# Create a separate passwordless SSH keypair and copy it to the server
ssh-keygen -t ed25519 -f ~/.ssh/id_borg
ssh-copy-id -i ~/.ssh/id_borg borg@192.168.x.x
# SERVER:
# restrict borg SSH key permissions by editing `/home/borg/.ssh/authorized_keys` and modifying the first line to look like this:
command="borg serve --restrict-to-path /tank/backups",restrict ssh-ed25519 AAAAC3Nz... (remainder of key)
# HOST MACHINE:
# init the repository
export BORG_REPO=ssh://borg@192.168.x.x/tank/backups/reponame
export BORG_RSH="ssh -i ~/.ssh/id_borg"
borg init --encryption=repokey

Creating a Backup

borg create ::$(date +%Y-%m-%d) ~/Downloads ~/Documents

Pruning Backups

borg prune --list --keep-daily 7 --keep-weekly 4 --keep-monthly 6

Compacting

borg compact

## Borg Frontends - Vorta - Pika - UI for the following: - Repo/ssh key creation - Scheduled backups - Pruning - Diff/mount/restore - Folder/file selection/exclusion
![Vorta screenshot](/presentations/homelab-storage/vorta.png) ![Pika screenshot](/presentations/homelab-storage/pika.png)

Questions