refactor(borgbackup): use visible directories with semantic subvolume names

Changes staging directories from hidden to visible and aligns backup paths with actual BTRFS subvolume naming conventions for better clarity when browsing archives.
This commit is contained in:
♥ Minnie ♥ 2025-10-08 15:53:15 +08:00
parent 2c286d65fb
commit 26c08000a0
Signed by: jasmine
GPG key ID: 8563E358D4E8040E
4 changed files with 56 additions and 56 deletions

View file

@ -10,35 +10,35 @@
# Create staging directory before borg service starts
systemd.tmpfiles.rules = [
"d /.staging-offsite 0755 root root -"
"d /subvolumes-offsite 0755 root root -"
];
services.borgbackup.jobs."offsite" = {
# Allow writing to staging directory
readWritePaths = [ "/.staging-offsite" ];
readWritePaths = [ "/subvolumes-offsite" ];
# Create staging snapshots before backup (independent from onsite)
preHook = ''
# Create read-only staging snapshots for home directory
${pkgs.btrfs-progs}/bin/btrfs subvolume snapshot -r \
"/home/sajenim" "/.staging-offsite/home"
"/home/sajenim" "/subvolumes-offsite/hm-sajenim"
'';
# Backup explicit home directories and persistent files
paths = [
# Home directories (valuable user data only)
"/.staging-offsite/home/Documents"
"/.staging-offsite/home/Pictures"
"/.staging-offsite/home/Videos"
"/.staging-offsite/home/Music"
"/.staging-offsite/home/Downloads"
"/.staging-offsite/home/Academics"
"/.staging-offsite/home/Notes"
"/.staging-offsite/home/Library"
"/subvolumes-offsite/hm-sajenim/Documents"
"/subvolumes-offsite/hm-sajenim/Pictures"
"/subvolumes-offsite/hm-sajenim/Videos"
"/subvolumes-offsite/hm-sajenim/Music"
"/subvolumes-offsite/hm-sajenim/Downloads"
"/subvolumes-offsite/hm-sajenim/Academics"
"/subvolumes-offsite/hm-sajenim/Notes"
"/subvolumes-offsite/hm-sajenim/Library"
# Dotfiles (critical user configuration)
"/.staging-offsite/home/.ssh"
"/.staging-offsite/home/.gnupg"
"/subvolumes-offsite/hm-sajenim/.ssh"
"/subvolumes-offsite/hm-sajenim/.gnupg"
# Files from persist.nix (restore to /persist)
"/etc/machine-id"
@ -57,7 +57,7 @@
# Remove staging snapshots after backup completes
postHook = ''
${pkgs.btrfs-progs}/bin/btrfs subvolume delete \
"/.staging-offsite/home"
"/subvolumes-offsite/hm-sajenim"
'';
# Remote repository configuration

View file

@ -8,35 +8,35 @@ in {
# Create staging directory before borg service starts
systemd.tmpfiles.rules = [
"d /.staging-onsite 0755 root root -"
"d /subvolumes-onsite 0755 root root -"
];
services.borgbackup.jobs."onsite" = {
# Allow writing to staging directory
readWritePaths = [ "/.staging-onsite" ];
readWritePaths = [ "/subvolumes-onsite" ];
# Create staging snapshots before backup (independent from offsite)
preHook = ''
# Create read-only staging snapshots for home directory
${pkgs.btrfs-progs}/bin/btrfs subvolume snapshot -r \
"/home/sajenim" "/.staging-onsite/home"
"/home/sajenim" "/subvolumes-onsite/hm-sajenim"
'';
# Backup explicit home directories and persistent files
paths = [
# Home directories (valuable user data only)
"/.staging-onsite/home/Documents"
"/.staging-onsite/home/Pictures"
"/.staging-onsite/home/Videos"
"/.staging-onsite/home/Music"
"/.staging-onsite/home/Downloads"
"/.staging-onsite/home/Academics"
"/.staging-onsite/home/Notes"
"/.staging-onsite/home/Library"
"/subvolumes-onsite/hm-sajenim/Documents"
"/subvolumes-onsite/hm-sajenim/Pictures"
"/subvolumes-onsite/hm-sajenim/Videos"
"/subvolumes-onsite/hm-sajenim/Music"
"/subvolumes-onsite/hm-sajenim/Downloads"
"/subvolumes-onsite/hm-sajenim/Academics"
"/subvolumes-onsite/hm-sajenim/Notes"
"/subvolumes-onsite/hm-sajenim/Library"
# Dotfiles (critical user configuration)
"/.staging-onsite/home/.ssh"
"/.staging-onsite/home/.gnupg"
"/subvolumes-onsite/hm-sajenim/.ssh"
"/subvolumes-onsite/hm-sajenim/.gnupg"
# Files from persist.nix (restore to /persist)
"/etc/machine-id"
@ -55,7 +55,7 @@ in {
# Remove staging snapshots after backup completes
postHook = ''
${pkgs.btrfs-progs}/bin/btrfs subvolume delete \
"/.staging-onsite/home"
"/subvolumes-onsite/hm-sajenim"
'';
# Onsite repository configuration (backup to viridian over SSH)

View file

@ -10,35 +10,35 @@
# Create staging directory before borg service starts
systemd.tmpfiles.rules = [
"d /.staging-offsite 0755 root root -"
"d /subvolumes-offsite 0755 root root -"
];
services.borgbackup.jobs."offsite" = {
# Allow writing to staging directory
readWritePaths = [ "/.staging-offsite" ];
readWritePaths = [ "/subvolumes-offsite" ];
# Create staging snapshots before backup (independent from onsite)
preHook = ''
# Create read-only staging snapshots for each service
for subvol in containers forgejo lighttpd minecraft opengist; do
# Map config names to actual subvolume paths
for subvol in srv-containers srv-forgejo srv-lighttpd srv-minecraft srv-opengist; do
# Map subvolume names to actual paths
case "$subvol" in
containers) src="/srv/multimedia/containers" ;;
*) src="/srv/$subvol" ;;
srv-containers) src="/srv/multimedia/containers" ;;
srv-*) src="/srv/''${subvol#srv-}" ;;
esac
${pkgs.btrfs-progs}/bin/btrfs subvolume snapshot -r \
"$src" "/.staging-offsite/$subvol"
"$src" "/subvolumes-offsite/$subvol"
done
'';
# Backup staging snapshots and explicit persistent files
paths = [
"/.staging-offsite/containers"
"/.staging-offsite/forgejo"
"/.staging-offsite/lighttpd"
"/.staging-offsite/minecraft"
"/.staging-offsite/opengist"
"/subvolumes-offsite/srv-containers"
"/subvolumes-offsite/srv-forgejo"
"/subvolumes-offsite/srv-lighttpd"
"/subvolumes-offsite/srv-minecraft"
"/subvolumes-offsite/srv-opengist"
# Files from persist.nix (restore to /persist)
"/etc/machine-id"
@ -56,9 +56,9 @@
# Remove staging snapshots after backup completes
postHook = ''
for subvol in containers forgejo lighttpd minecraft opengist; do
for subvol in srv-containers srv-forgejo srv-lighttpd srv-minecraft srv-opengist; do
${pkgs.btrfs-progs}/bin/btrfs subvolume delete \
"/.staging-offsite/$subvol"
"/subvolumes-offsite/$subvol"
done
'';

View file

@ -17,35 +17,35 @@ in {
# Create staging directory before borg service starts
systemd.tmpfiles.rules = [
"d /.staging-onsite 0755 root root -"
"d /subvolumes-onsite 0755 root root -"
];
services.borgbackup.jobs."onsite" = {
# Allow writing to staging directory
readWritePaths = [ "/.staging-onsite" ];
readWritePaths = [ "/subvolumes-onsite" ];
# Create staging snapshots before backup (independent from offsite)
preHook = ''
# Create read-only staging snapshots for each service
for subvol in containers forgejo lighttpd minecraft opengist; do
# Map config names to actual subvolume paths
for subvol in srv-containers srv-forgejo srv-lighttpd srv-minecraft srv-opengist; do
# Map subvolume names to actual paths
case "$subvol" in
containers) src="/srv/multimedia/containers" ;;
*) src="/srv/$subvol" ;;
srv-containers) src="/srv/multimedia/containers" ;;
srv-*) src="/srv/''${subvol#srv-}" ;;
esac
${pkgs.btrfs-progs}/bin/btrfs subvolume snapshot -r \
"$src" "/.staging-onsite/$subvol"
"$src" "/subvolumes-onsite/$subvol"
done
'';
# Backup staging snapshots and explicit persistent files
paths = [
"/.staging-onsite/containers"
"/.staging-onsite/forgejo"
"/.staging-onsite/lighttpd"
"/.staging-onsite/minecraft"
"/.staging-onsite/opengist"
"/subvolumes-onsite/srv-containers"
"/subvolumes-onsite/srv-forgejo"
"/subvolumes-onsite/srv-lighttpd"
"/subvolumes-onsite/srv-minecraft"
"/subvolumes-onsite/srv-opengist"
# Files from persist.nix (restore to /persist)
"/etc/machine-id"
@ -63,9 +63,9 @@ in {
# Remove staging snapshots after backup completes
postHook = ''
for subvol in containers forgejo lighttpd minecraft opengist; do
for subvol in srv-containers srv-forgejo srv-lighttpd srv-minecraft srv-opengist; do
${pkgs.btrfs-progs}/bin/btrfs subvolume delete \
"/.staging-onsite/$subvol"
"/subvolumes-onsite/$subvol"
done
'';