File tree Expand file tree Collapse file tree 5 files changed +96
-0
lines changed
Expand file tree Collapse file tree 5 files changed +96
-0
lines changed Original file line number Diff line number Diff line change 1+ { pkgs , config , lib , ... } :
2+ {
3+ age . secrets . restic-password = {
4+ file = ./secrets/restic-password.age ;
5+ owner = "marie" ;
6+ group = "users" ;
7+ } ;
8+ systemd . services . backup = {
9+ after = [ "network-online.target" ] ;
10+ wants = [ "network-online.target" ] ;
11+ serviceConfig = {
12+ PrivateMounts = true ;
13+ SystemCallFilter = [ "@system-service" "@mount" ] ;
14+ } ;
15+ environment = {
16+ RESTIC_REPOSITORY = "sftp:marie@marie-nas.fritz.box:/srv/restic/marie" ;
17+ RESTIC_PASSWORD_FILE = config . age . secrets . restic-password . path ;
18+ SSH_AUTH_SOCK = "/run/user/1000/ssh-agent" ;
19+ HOME = "/home/marie" ;
20+ } ;
21+ path = with pkgs ; [ restic util-linux btrfs-progs config . programs . ssh . package config . security . sudo . package ] ;
22+ script = ''
23+ set -euo pipefail
24+ SNAPSHOT_NAME="@restic-$(date "+%F_%k-%M-%S")"
25+ btrfs subvolume snapshot /home "/home/$SNAPSHOT_NAME"
26+
27+ function cleanup() {
28+ mount -t btrfs -o subvol=home ${ config . fileSystems . "/home" . device } /home
29+ btrfs subvolume delete "/home/$SNAPSHOT_NAME"
30+ }
31+
32+ trap cleanup EXIT
33+
34+ umount /home
35+ mount -t btrfs -o subvol="/home/$SNAPSHOT_NAME" '${ config . fileSystems . "/home" . device } ' /home
36+
37+ sudo \
38+ --user=marie \
39+ --preserve-env=RESTIC_REPOSITORY,RESTIC_PASSWORD_FILE,SSH_AUTH_SOCK \
40+ restic backup \
41+ --exclude-caches \
42+ --exclude-file "${ ./scripts/restic-excludes.txt } " \
43+ --tag home \
44+ --one-file-system \
45+ "$HOME"
46+ '' ;
47+ } ;
48+ }
Original file line number Diff line number Diff line change 22{
33 imports = with inputs ; [
44 home-manager-unstable . nixosModules . default
5+ agenix . nixosModules . default
56 ./hardware.nix
67 ./gaming.nix
78 ./suspend-fix.nix
89 ./tailscale.nix
910 ./syncthing.nix
1011 ./wireshark.nix
12+ ./backup.nix
1113 ] ;
1214
1315 uwumarie . profiles = {
Original file line number Diff line number Diff line change 1+ $HOME/**/Cache
2+ $HOME/**/Caches
3+ $HOME/**/cache
4+ $HOME/**/caches
5+ $HOME/**/.cache
6+ $HOME/**/__pycache__
7+
8+ $HOME/.config/*/Cache
9+ $HOME/.config/*/GPUCache
10+ $HOME/.config/*/ShaderCache
11+ $HOME/.config/*/DawnCache
12+ $HOME/.config/*/DawnGraphiteCache
13+ $HOME/.config/*/DawnWebGPUCache
14+
15+ $HOME/.config/VSCodium/CachedData
16+ $HOME/.config/VSCodium/CachedExtensions
17+ $HOME/.config/VSCodium/logs
18+
19+ $HOME/.local/share/Steam
20+ $HOME/.local/share/pnpm
21+ $HOME/.local/share/containers
22+ $HOME/.local/share/umu
23+
24+ $HOME/.rustup
25+ $HOME/.yarn
26+ $HOME/.npm
27+ $HOME/.jdks
28+ $HOME/.cargo
29+ $HOME/.compose-cache
30+ $HOME/.ccache
31+ $HOME/.android
32+ $HOME/.gradle
33+
34+ $HOME/.var/app/com.usebottles.bottles
Original file line number Diff line number Diff line change 1+ age-encryption.org/v1
2+ -> ssh-ed25519 GkDrBg hlklf6O6XbDOm1t42koXo3lqCyhk6vfkKVEmS8VRWwo
3+ AwRFsyGEo2GvLaR3dxqBWs5LtEZN3BeVz/Phr5HRsIk
4+ -> ssh-ed25519 /tLDqA kC/Sxf9S1/3uUoY5XfEsfA1+52s+EgToc/ktAyWdwz8
5+ 1nI4VDwqmrgNDf/GxFDqFJIoKipSzO9MNwW9t3VNxqs
6+ -> ssh-ed25519 kl9Tcw 0rZ7RBdPuMItattk4JIrchPakWp8JWojFHWHLVy9Im8
7+ qBPidAlVVxbKSm9bW2/PdsmdahZ76IKBWjX+a2XtDss
8+ --- ZJMS3G8LpYfS6t68+lkK19DmR4XvKLecHSx6QT27p+A
9+ i����:�v�V�i�ៗ�1���n����^�*��\p�@i�-@?�V6�dM�e@ن��(�����h�u�� �*2}�K�N0�
Original file line number Diff line number Diff line change 99 wsl = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEpKCSJGPFfckgr1/X1Rv7jeOe9E8tYmP1iqogzSXF+u" ] ;
1010 gitlabber = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBFxL7AqowWxKzJqrj8Mr2MDF3NDbyExAPwKjohoCx/t" ] ;
1111 marie-nas = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILwvQy3cK9gGwFEf5UGCxQ61j8Kv30JDAZ39FOtKkrCQ" ] ;
12+ marie-desktop-host = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPSpnu/du04AEB2LuwIHJU5CZwBFsMLWUhNgn0+9tlte root@marie-desktop" ] ;
1213 allSystems = artemis ++ delphi ++ wsl ++ marie-nas ;
1314 users = marie-desktop-wsl ++ marie-desktop ;
1415in
4243 "../hosts/gitlabber/cachix-auth-token.age" . publicKeys = users ++ gitlabber ;
4344 "../hosts/gitlabber/forgejo-runner.age" . publicKeys = users ++ gitlabber ;
4445 "../hosts/artemis/applications/hedgedoc/env.age" . publicKeys = users ++ artemis ;
46+
47+ "../hosts/marie-desktop/secrets/restic-password.age" . publicKeys = marie-desktop ++ marie-desktop-host ;
4548}
You can’t perform that action at this time.
0 commit comments