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:
parent
2c286d65fb
commit
26c08000a0
4 changed files with 56 additions and 56 deletions
|
|
@ -10,35 +10,35 @@
|
||||||
|
|
||||||
# Create staging directory before borg service starts
|
# Create staging directory before borg service starts
|
||||||
systemd.tmpfiles.rules = [
|
systemd.tmpfiles.rules = [
|
||||||
"d /.staging-offsite 0755 root root -"
|
"d /subvolumes-offsite 0755 root root -"
|
||||||
];
|
];
|
||||||
|
|
||||||
services.borgbackup.jobs."offsite" = {
|
services.borgbackup.jobs."offsite" = {
|
||||||
# Allow writing to staging directory
|
# Allow writing to staging directory
|
||||||
readWritePaths = [ "/.staging-offsite" ];
|
readWritePaths = [ "/subvolumes-offsite" ];
|
||||||
|
|
||||||
# Create staging snapshots before backup (independent from onsite)
|
# Create staging snapshots before backup (independent from onsite)
|
||||||
preHook = ''
|
preHook = ''
|
||||||
# Create read-only staging snapshots for home directory
|
# Create read-only staging snapshots for home directory
|
||||||
${pkgs.btrfs-progs}/bin/btrfs subvolume snapshot -r \
|
${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
|
# Backup explicit home directories and persistent files
|
||||||
paths = [
|
paths = [
|
||||||
# Home directories (valuable user data only)
|
# Home directories (valuable user data only)
|
||||||
"/.staging-offsite/home/Documents"
|
"/subvolumes-offsite/hm-sajenim/Documents"
|
||||||
"/.staging-offsite/home/Pictures"
|
"/subvolumes-offsite/hm-sajenim/Pictures"
|
||||||
"/.staging-offsite/home/Videos"
|
"/subvolumes-offsite/hm-sajenim/Videos"
|
||||||
"/.staging-offsite/home/Music"
|
"/subvolumes-offsite/hm-sajenim/Music"
|
||||||
"/.staging-offsite/home/Downloads"
|
"/subvolumes-offsite/hm-sajenim/Downloads"
|
||||||
"/.staging-offsite/home/Academics"
|
"/subvolumes-offsite/hm-sajenim/Academics"
|
||||||
"/.staging-offsite/home/Notes"
|
"/subvolumes-offsite/hm-sajenim/Notes"
|
||||||
"/.staging-offsite/home/Library"
|
"/subvolumes-offsite/hm-sajenim/Library"
|
||||||
|
|
||||||
# Dotfiles (critical user configuration)
|
# Dotfiles (critical user configuration)
|
||||||
"/.staging-offsite/home/.ssh"
|
"/subvolumes-offsite/hm-sajenim/.ssh"
|
||||||
"/.staging-offsite/home/.gnupg"
|
"/subvolumes-offsite/hm-sajenim/.gnupg"
|
||||||
|
|
||||||
# Files from persist.nix (restore to /persist)
|
# Files from persist.nix (restore to /persist)
|
||||||
"/etc/machine-id"
|
"/etc/machine-id"
|
||||||
|
|
@ -57,7 +57,7 @@
|
||||||
# Remove staging snapshots after backup completes
|
# Remove staging snapshots after backup completes
|
||||||
postHook = ''
|
postHook = ''
|
||||||
${pkgs.btrfs-progs}/bin/btrfs subvolume delete \
|
${pkgs.btrfs-progs}/bin/btrfs subvolume delete \
|
||||||
"/.staging-offsite/home"
|
"/subvolumes-offsite/hm-sajenim"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# Remote repository configuration
|
# Remote repository configuration
|
||||||
|
|
|
||||||
|
|
@ -8,35 +8,35 @@ in {
|
||||||
|
|
||||||
# Create staging directory before borg service starts
|
# Create staging directory before borg service starts
|
||||||
systemd.tmpfiles.rules = [
|
systemd.tmpfiles.rules = [
|
||||||
"d /.staging-onsite 0755 root root -"
|
"d /subvolumes-onsite 0755 root root -"
|
||||||
];
|
];
|
||||||
|
|
||||||
services.borgbackup.jobs."onsite" = {
|
services.borgbackup.jobs."onsite" = {
|
||||||
# Allow writing to staging directory
|
# Allow writing to staging directory
|
||||||
readWritePaths = [ "/.staging-onsite" ];
|
readWritePaths = [ "/subvolumes-onsite" ];
|
||||||
|
|
||||||
# Create staging snapshots before backup (independent from offsite)
|
# Create staging snapshots before backup (independent from offsite)
|
||||||
preHook = ''
|
preHook = ''
|
||||||
# Create read-only staging snapshots for home directory
|
# Create read-only staging snapshots for home directory
|
||||||
${pkgs.btrfs-progs}/bin/btrfs subvolume snapshot -r \
|
${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
|
# Backup explicit home directories and persistent files
|
||||||
paths = [
|
paths = [
|
||||||
# Home directories (valuable user data only)
|
# Home directories (valuable user data only)
|
||||||
"/.staging-onsite/home/Documents"
|
"/subvolumes-onsite/hm-sajenim/Documents"
|
||||||
"/.staging-onsite/home/Pictures"
|
"/subvolumes-onsite/hm-sajenim/Pictures"
|
||||||
"/.staging-onsite/home/Videos"
|
"/subvolumes-onsite/hm-sajenim/Videos"
|
||||||
"/.staging-onsite/home/Music"
|
"/subvolumes-onsite/hm-sajenim/Music"
|
||||||
"/.staging-onsite/home/Downloads"
|
"/subvolumes-onsite/hm-sajenim/Downloads"
|
||||||
"/.staging-onsite/home/Academics"
|
"/subvolumes-onsite/hm-sajenim/Academics"
|
||||||
"/.staging-onsite/home/Notes"
|
"/subvolumes-onsite/hm-sajenim/Notes"
|
||||||
"/.staging-onsite/home/Library"
|
"/subvolumes-onsite/hm-sajenim/Library"
|
||||||
|
|
||||||
# Dotfiles (critical user configuration)
|
# Dotfiles (critical user configuration)
|
||||||
"/.staging-onsite/home/.ssh"
|
"/subvolumes-onsite/hm-sajenim/.ssh"
|
||||||
"/.staging-onsite/home/.gnupg"
|
"/subvolumes-onsite/hm-sajenim/.gnupg"
|
||||||
|
|
||||||
# Files from persist.nix (restore to /persist)
|
# Files from persist.nix (restore to /persist)
|
||||||
"/etc/machine-id"
|
"/etc/machine-id"
|
||||||
|
|
@ -55,7 +55,7 @@ in {
|
||||||
# Remove staging snapshots after backup completes
|
# Remove staging snapshots after backup completes
|
||||||
postHook = ''
|
postHook = ''
|
||||||
${pkgs.btrfs-progs}/bin/btrfs subvolume delete \
|
${pkgs.btrfs-progs}/bin/btrfs subvolume delete \
|
||||||
"/.staging-onsite/home"
|
"/subvolumes-onsite/hm-sajenim"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# Onsite repository configuration (backup to viridian over SSH)
|
# Onsite repository configuration (backup to viridian over SSH)
|
||||||
|
|
|
||||||
|
|
@ -10,35 +10,35 @@
|
||||||
|
|
||||||
# Create staging directory before borg service starts
|
# Create staging directory before borg service starts
|
||||||
systemd.tmpfiles.rules = [
|
systemd.tmpfiles.rules = [
|
||||||
"d /.staging-offsite 0755 root root -"
|
"d /subvolumes-offsite 0755 root root -"
|
||||||
];
|
];
|
||||||
|
|
||||||
services.borgbackup.jobs."offsite" = {
|
services.borgbackup.jobs."offsite" = {
|
||||||
# Allow writing to staging directory
|
# Allow writing to staging directory
|
||||||
readWritePaths = [ "/.staging-offsite" ];
|
readWritePaths = [ "/subvolumes-offsite" ];
|
||||||
|
|
||||||
# Create staging snapshots before backup (independent from onsite)
|
# Create staging snapshots before backup (independent from onsite)
|
||||||
preHook = ''
|
preHook = ''
|
||||||
# Create read-only staging snapshots for each service
|
# Create read-only staging snapshots for each service
|
||||||
for subvol in containers forgejo lighttpd minecraft opengist; do
|
for subvol in srv-containers srv-forgejo srv-lighttpd srv-minecraft srv-opengist; do
|
||||||
# Map config names to actual subvolume paths
|
# Map subvolume names to actual paths
|
||||||
case "$subvol" in
|
case "$subvol" in
|
||||||
containers) src="/srv/multimedia/containers" ;;
|
srv-containers) src="/srv/multimedia/containers" ;;
|
||||||
*) src="/srv/$subvol" ;;
|
srv-*) src="/srv/''${subvol#srv-}" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
${pkgs.btrfs-progs}/bin/btrfs subvolume snapshot -r \
|
${pkgs.btrfs-progs}/bin/btrfs subvolume snapshot -r \
|
||||||
"$src" "/.staging-offsite/$subvol"
|
"$src" "/subvolumes-offsite/$subvol"
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# Backup staging snapshots and explicit persistent files
|
# Backup staging snapshots and explicit persistent files
|
||||||
paths = [
|
paths = [
|
||||||
"/.staging-offsite/containers"
|
"/subvolumes-offsite/srv-containers"
|
||||||
"/.staging-offsite/forgejo"
|
"/subvolumes-offsite/srv-forgejo"
|
||||||
"/.staging-offsite/lighttpd"
|
"/subvolumes-offsite/srv-lighttpd"
|
||||||
"/.staging-offsite/minecraft"
|
"/subvolumes-offsite/srv-minecraft"
|
||||||
"/.staging-offsite/opengist"
|
"/subvolumes-offsite/srv-opengist"
|
||||||
|
|
||||||
# Files from persist.nix (restore to /persist)
|
# Files from persist.nix (restore to /persist)
|
||||||
"/etc/machine-id"
|
"/etc/machine-id"
|
||||||
|
|
@ -56,9 +56,9 @@
|
||||||
|
|
||||||
# Remove staging snapshots after backup completes
|
# Remove staging snapshots after backup completes
|
||||||
postHook = ''
|
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 \
|
${pkgs.btrfs-progs}/bin/btrfs subvolume delete \
|
||||||
"/.staging-offsite/$subvol"
|
"/subvolumes-offsite/$subvol"
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,35 +17,35 @@ in {
|
||||||
|
|
||||||
# Create staging directory before borg service starts
|
# Create staging directory before borg service starts
|
||||||
systemd.tmpfiles.rules = [
|
systemd.tmpfiles.rules = [
|
||||||
"d /.staging-onsite 0755 root root -"
|
"d /subvolumes-onsite 0755 root root -"
|
||||||
];
|
];
|
||||||
|
|
||||||
services.borgbackup.jobs."onsite" = {
|
services.borgbackup.jobs."onsite" = {
|
||||||
# Allow writing to staging directory
|
# Allow writing to staging directory
|
||||||
readWritePaths = [ "/.staging-onsite" ];
|
readWritePaths = [ "/subvolumes-onsite" ];
|
||||||
|
|
||||||
# Create staging snapshots before backup (independent from offsite)
|
# Create staging snapshots before backup (independent from offsite)
|
||||||
preHook = ''
|
preHook = ''
|
||||||
# Create read-only staging snapshots for each service
|
# Create read-only staging snapshots for each service
|
||||||
for subvol in containers forgejo lighttpd minecraft opengist; do
|
for subvol in srv-containers srv-forgejo srv-lighttpd srv-minecraft srv-opengist; do
|
||||||
# Map config names to actual subvolume paths
|
# Map subvolume names to actual paths
|
||||||
case "$subvol" in
|
case "$subvol" in
|
||||||
containers) src="/srv/multimedia/containers" ;;
|
srv-containers) src="/srv/multimedia/containers" ;;
|
||||||
*) src="/srv/$subvol" ;;
|
srv-*) src="/srv/''${subvol#srv-}" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
${pkgs.btrfs-progs}/bin/btrfs subvolume snapshot -r \
|
${pkgs.btrfs-progs}/bin/btrfs subvolume snapshot -r \
|
||||||
"$src" "/.staging-onsite/$subvol"
|
"$src" "/subvolumes-onsite/$subvol"
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# Backup staging snapshots and explicit persistent files
|
# Backup staging snapshots and explicit persistent files
|
||||||
paths = [
|
paths = [
|
||||||
"/.staging-onsite/containers"
|
"/subvolumes-onsite/srv-containers"
|
||||||
"/.staging-onsite/forgejo"
|
"/subvolumes-onsite/srv-forgejo"
|
||||||
"/.staging-onsite/lighttpd"
|
"/subvolumes-onsite/srv-lighttpd"
|
||||||
"/.staging-onsite/minecraft"
|
"/subvolumes-onsite/srv-minecraft"
|
||||||
"/.staging-onsite/opengist"
|
"/subvolumes-onsite/srv-opengist"
|
||||||
|
|
||||||
# Files from persist.nix (restore to /persist)
|
# Files from persist.nix (restore to /persist)
|
||||||
"/etc/machine-id"
|
"/etc/machine-id"
|
||||||
|
|
@ -63,9 +63,9 @@ in {
|
||||||
|
|
||||||
# Remove staging snapshots after backup completes
|
# Remove staging snapshots after backup completes
|
||||||
postHook = ''
|
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 \
|
${pkgs.btrfs-progs}/bin/btrfs subvolume delete \
|
||||||
"/.staging-onsite/$subvol"
|
"/subvolumes-onsite/$subvol"
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue