1
0

modules/backup: support excluding paths

This commit is contained in:
clerie 2023-06-28 18:09:03 +02:00
parent 80cc6522da
commit 942d226099
2 changed files with 13 additions and 9 deletions

View File

@ -9,16 +9,17 @@
"/var/lib" "/var/lib"
]; ];
exclude = [ exclude = [
"/home/*/.local/share/Trash/" "/home/*/.local/share/Trash/*"
"/home/*/.config/*.log" "/home/*/.config/*.log"
"/home/*/.local/*.log" "/home/*/.local/*.log"
"/home/*/.cache/" "/home/*/.cache/*"
"/home/*/.config/*[Cc]ache*/" "/home/*/.config/*[Cc]ache*/*"
"/home/*/.mozilla/*/cache/" "/home/*/.mozilla/*/cache/*"
"/home/*/.thumbnails/" "/home/*/.thumbnails/*"
"/home/*/.config/Element/Cache/*"
"/home/clerie/tmp/" "/home/clerie/tmp/*"
"/home/clere/Downloads/" "/home/clere/Downloads/*"
]; ];
}; };
}; };

View File

@ -40,14 +40,17 @@ let
export RESTIC_PASSWORD_FILE=${jobPasswordFile} export RESTIC_PASSWORD_FILE=${jobPasswordFile}
export RESTIC_REPOSITORY="rest:https://${targetUsername}:$(cat ${targetPasswordFile})@${targetOptions.serverName}${repoPath}" export RESTIC_REPOSITORY="rest:https://${targetUsername}:$(cat ${targetPasswordFile})@${targetOptions.serverName}${repoPath}"
export RESTIC_PROGRESS_FPS=0.1
restic snapshots || restic init restic snapshots || restic init
restic backup ${optionalString (jobOptions.exclude != []) (pkgs.writeText "clerie-backup-${jobName}-${targetName}-excludes" (concatStringsSep "\n" jobOptions.exclude))} ${escapeShellArgs jobOptions.paths} restic backup ${optionalString (jobOptions.exclude != []) "--exclude-file ${pkgs.writeText "clerie-backup-${jobName}-${targetName}-excludes" (concatStringsSep "\n" jobOptions.exclude)}"} ${escapeShellArgs jobOptions.paths}
restic check restic check
${optionalString (config.clerie.monitoring.enable) ''
echo "clerie_backup_last_successful_run_time{backup_job=\"${jobName}\", backup_target=\"${targetName}\"} $(date +%s)" > /var/lib/prometheus-node-exporter/textfiles/clerie-backup-${jobName}-${targetName}.prom echo "clerie_backup_last_successful_run_time{backup_job=\"${jobName}\", backup_target=\"${targetName}\"} $(date +%s)" > /var/lib/prometheus-node-exporter/textfiles/clerie-backup-${jobName}-${targetName}.prom
''}
''; '';
} }
) jobTargetPairs); ) jobTargetPairs);