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
 | 
			
		||||
  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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue