My Custom NAS

Oct 8, 2024    #homelab  

Introduction

In my last post, I began discussing the importance of having a robust and cost-effective backup solution. With data becoming more valuable than ever, finding the right balance between efficiency, reliability, and affordability is crucial. Now, it’s time to dive deeper into my thought process and the specific steps I took to build a refined backup system that ticks all these boxes.

In this post, I’ll walk you through the development of my new backup plan, which includes leveraging a pre-built NAS and affordable hardware to create an efficient, space-conscious solution. I’ll also introduce an upgraded version of the gbackup utility, designed to make backing up and restoring data effortless. Let’s get started!

Why

Before deciding to build my own NAS from individual PC components, I considered purchasing a pre-built NAS from a third-party provider. However, several factors made me reconsider.

So the main goal of the NAS is to:

NAS Components

Inspired by Michael Stapelberg’s blog post.

TypeNameLink
CasePC SilverStone SG05BB LITEhttps://www.codi-tek.com/Caixa-Pc-Silverstone-Sg05bb-Lite-Desktop-Housing-Preto-Installation--P335305.html?campanha_track=comparadorgg
MotherboardAsRock B450 Gaming ITX/achttps://www.aquario.pt/pt/product/asrock-motherboard-mini-itx-asrock-fatal1ty-b450-90-mxb870-a0uayz?srsltid=AfmBOoppr6E_38Yj8UEVSH9knuz-ow3_4jxVs2yKpyuWN08b1TcgCPKM
CPU CoolerCooler CPU Noctua NH-L12Shttps://www.pcdiga.com/componentes/coolers-cpu/air-cooling-cpu/cooler-cpu-noctua-nh-l12s-nh-l12s-9010018000054
Power SupplySilverstone ST30SF V2 SFX 300Whttps://www.pccomponentes.pt/silverstone-st30sf-v2-sfx-300w?srsltid=AfmBOopQ37FC8LHGhw0uuC90dXVXAfWZ-ErGi8MvB8bQvW0NrBwHZ5NU
System DiskIntenso NVMe 250 GBhttps://www.worten.pt/produtos/intenso-ssd-250gb-premium-m-2-pcie-pci-express-3-0-nvme-mrkean-4034303031146
Data Disks2 SSDs 250 GB SamsungAlready had these two
Case FanNoctua NF-S12A ULNhttps://www.fnac.pt/mp1544968/Noctua-NF-S12A-ULN-Pasta-de-computador-Ventoinha
RAM8GB DDR4 2400 RAM DIMM (1x8GB) CL15 1.2V G.SKILL AEGIShttps://chip7.pt/componentes-hardware/memoria-ram/memoria-ram-ddr4/gskill/8gb-ddr4-2400-memoria-ram-dimm-1x8gb-cl15-12v-gskill-aegis-f4-2400c15s?srsltid=AfmBOoqkPL_0bXIdGCiWWybDX4jiGiduBAJU8pndqjOD2OCEX_MdQ32Z
CPUAMD Ryzen 3 4300G 8-Core 3.8GHz 4MB Skt AM4https://www.onbit.pt/processador-amd-ryzen-3-4300g-8-core-3-8ghz-4mb-skt-am4.html

It’s worth mentioning that there are a few optional components to consider, such as:

I chose to invest in these optional components to ensure a longer-lasting and more efficient system. By prioritizing longevity, I can enhance performance and reduce the risk of overheating, ultimately contributing to the overall reliability of my NAS.

NAS Configuration

To configure my NAS, I followed these steps:

  1. Installed Debian 12 (No Desktop Environment)
  1. Set Up Static IP Address
  1. Setup Wake on Lan
  1. Configure ZFS
sudo zpool create -f -o ashift=12 brun0nas1 /dev/disk/by-id/ata-KINGSTON_SA400S37240G_50026B76861689C2 /dev/disk/by-id/ata-KINGSTON_SV300S37A240G_50026B766A04AC5E
sudo zfs create brun0nas1/backupExternal && sudo zfs create brun0nas1/backupProxmox
sudo zpool set autotrim=on brun0nas1
sudo systemctl enable --now zfs-scrub@brun0nas1.timer
\# /etc/systemd/system/zfs-scrub@brun0nas1.timer

[Unit]
Description=Monthly zpool scrub on brun0nas1

[Timer]
OnCalendar=monthly
AccuracySec=1h
Persistent=true

[Service]
ExecStart=/usr/bin/zpool scrub brun0nas1

[Install]
WantedBy=multi-user.target
  1. Configure Proxmox Backup Server (PBS)
wget https://enterprise.proxmox.com/debian/proxmox-release-bookworm.gpg -O /etc/apt/trusted.gpg.d/proxmox-release-bookworm.gpg

\# added this to /etc/apt/sources.list
deb http://download.proxmox.com/debian/pbs bookworm pbs-no-subscription

s apt update
s apt install proxmox-backup-server
mkdir -p /mnt/datastore/backupExternal
mkdir -p /mnt/datastore/backupProxmox

s zfs set mountpoint=/mnt/datastore/backupProxmox brun0nas1/backupProxmox
s zfs set mountpoint=/mnt/datastore/backupProxmox brun0nas1/backupExternal
zfs list

NAME                       USED  AVAIL  REFER  MOUNTPOINT
brun0nas1                 1.02M   430G    96K  /brun0nas1
brun0nas1/backupExternal    96K   430G    96K  /mnt/datastore/backupExternal
brun0nas1/backupProxmox     96K   430G    96K  /mnt/datastore/backupProxmox

Gbackupv2

Backup Information

  1. External Hard Drive Setup
  1. Gbackup Configuration

Backup workflow

  1. Scheduled Incremental Backup (Every Friday at 1 PM)

The following steps outline how the incremental backup process occurs each Friday:

12:50 PM:
Gbackup sends a Wake-on-LAN (WoL) signal to power on the NAS

1:00 PM:
Proxmox Backup Server (PBS) performs an incremental backup of Proxmox virtual machines (VMs) and containers, saving the data to /backupProxmox
Gbackup uses the Proxmox API to check the status and results of the Proxmox backups for the current day
	
After PBS Backup Completion:
Gbackup backs up important directories from gokrazy, worklatop, pinute, ...
These are backed up to the external hard drive mounted at /mnt/external

Mirror Backup to NAS:
Gbackup then copies the contents of /mnt/external (which includes the aforementioned directories) to the NAS under /backupExternal

Shutdown NAS:
Once the backup process is complete, Gbackup powers off the NAS to conserve energy

Final backup structure

Obs: In the future, a second external hard drive will be connected to Pinute. Once a month, Gbackup will create a tarball of the backupProxmox and backupExternal folders on the NAS. These compressed backups will be saved to the secondary hard drive as an additional layer of redundancy.

Disaster Recovery



Next: Replace Proxmox Server