diff options
| -rw-r--r-- | host_vars/rpi5.local.yml | bin | 2390 -> 2394 bytes | |||
| -rw-r--r-- | host_vars/rpi5.local.yml.example | 2 | ||||
| -rw-r--r-- | molecule/raspberrypi/molecule.yml | 1 | ||||
| -rw-r--r-- | roles/backup/README.md | 75 | ||||
| -rw-r--r-- | roles/backup/meta/argument_specs.yml | 2 |
5 files changed, 78 insertions, 2 deletions
diff --git a/host_vars/rpi5.local.yml b/host_vars/rpi5.local.yml Binary files differindex 4a366424..b5708d51 100644 --- a/host_vars/rpi5.local.yml +++ b/host_vars/rpi5.local.yml diff --git a/host_vars/rpi5.local.yml.example b/host_vars/rpi5.local.yml.example index 1b6eb4fd..1ad9bc02 100644 --- a/host_vars/rpi5.local.yml.example +++ b/host_vars/rpi5.local.yml.example @@ -75,4 +75,4 @@ grafana_dashboards: - key: "${DS__VICTORIAMETRICS}" value: "prometheus" -backup_device: "/dev/sda2" +backup_device: "UUID=your_backup_device_uuid_here" diff --git a/molecule/raspberrypi/molecule.yml b/molecule/raspberrypi/molecule.yml index c913b75f..4832e8aa 100644 --- a/molecule/raspberrypi/molecule.yml +++ b/molecule/raspberrypi/molecule.yml @@ -20,6 +20,7 @@ platforms: "/run": "rw,exec" volumes: - "/sys/fs/cgroup:/sys/fs/cgroup:rw" + - "/dev:/dev:rw" cgroupns_mode: host provisioner: diff --git a/roles/backup/README.md b/roles/backup/README.md new file mode 100644 index 00000000..9984c4bd --- /dev/null +++ b/roles/backup/README.md @@ -0,0 +1,75 @@ +# Backup Role + +Mounts a dedicated backup drive on the target host. + +## Overview + +Prepares a dedicated storage device as the local backup destination S3-compatible object store (ex. Garage). + +## Configuration + +### Required Variables + +```yaml +backup_device: "PARTLABEL=backup" # no default — must set in host_vars +``` + +### Optional Variables + +```yaml +backup_mount_point: "/mnt/backup" +backup_fstype: "ext4" +backup_mount_options: "defaults,noatime" +``` + +## Preparing the Drive + +### 1. Install parted + +```bash +sudo apt install parted +``` + +### 2. Partition with a named label + +```bash +# check device name +lsblk + +# create GPT partition table + single labeled partition +sudo parted /dev/sdX --script mklabel gpt mkpart backup ext4 0% 100% +sudo parted /dev/nvme0nX --script mklabel gpt mkpart backup ext4 0% 100% + +# verify label +sudo parted /dev/sdX print +sudo parted /dev/nvme0nX print +``` + +### 3. Format as ext4 + +```bash +sudo mkfs.ext4 /dev/sdX1 +sudo mkfs.ext4 /dev/nvme0nXp1 + +# verify +sudo blkid /dev/sdX1 +sudo blkid /dev/nvme0nXp1 + +ls /dev/disk/by-partlabel/ +``` + +### 4. Set host variable + +In `host_vars/rpi5.local.yml`: + +```yaml +backup_device: "PARTLABEL=backup" +``` + +`PARTLABEL` is stable across reboots regardless of device enumeration order (`/dev/sda` vs `/dev/sdb`). +`ansible.posix.mount` handles `PARTLABEL=` values natively. + +## Notes + +- `noatime` mount option reduces unnecessary write cycles on the drive +- Role adds a persistent fstab entry — drive auto-mounts on reboot diff --git a/roles/backup/meta/argument_specs.yml b/roles/backup/meta/argument_specs.yml index 259173c1..459187ee 100644 --- a/roles/backup/meta/argument_specs.yml +++ b/roles/backup/meta/argument_specs.yml @@ -4,7 +4,7 @@ argument_specs: options: backup_device: type: "str" - description: "Block device to mount (e.g. /dev/sda1)" + description: "Device to mount (e.g. PARTLABEL=backup)" required: true backup_mount_point: type: "str" |
