Implement restic backup support for Darwin systems #52
Labels
No labels
bug
dependencies
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ops/nixos-skwrls#52
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Implement restic backup configuration for Darwin (macOS) systems to achieve feature parity with the existing NixOS backup implementation. Currently,
nixos/backups/provides automated backups to SFTP and AWS S3 for NixOS hosts, but nix-darwin does not support native restic options, requiring a custom implementation.Background
The NixOS backup system (
nixos/backups/) provides:Reference:
nixos/backups/client.nix,nixos/backups/shared.nix,nixos/backups/maintenance.nixKey Differences: NixOS vs Darwin
services.restic.backups/home/dos/Users/dosOnBootSec,OnUnitActiveSec,RandomizedDelaySecStartCalendarIntervalImplementation Tasks
1. Create Directory Structure
Create
darwin/backups/with the following files:default.nix- Main backup implementation using launchdshared.nix- Helper functions and configuration generatorsCatra-restic-excludes.txt- Per-host exclude patternsMadison-restic-excludes.txtPiper-restic-excludes.txt2. Implement
darwin/backups/shared.nixPort helper functions from NixOS version:
destinationslist (sftp, aws)secretPathshelpers for SOPS secret pathsmkBackupConfig,mkSftpConfig,mkAwsConfigconfiguration builders_module.args.backupHelpers3. Implement
darwin/backups/client.nixCore backup implementation:
skwrls.backups.pathsoption (defaults tovars.home)restic-backup-sftprestic-backup-aws--exclude-file,--skip-if-unchanged,--retry-lock 30mStartCalendarIntervalto run every 2 hours (equivalent to NixOS timer)RESTIC_PASSWORD_FILE,RESTIC_REPOSITORY, AWS credentials4. Create Host-Specific Exclude Files
Create exclude patterns for each Darwin host (similar to
Morgan-restic-excludes.txt):/Users/dos/*by defaultLibrary/CachesLibrary/Application Support/*/Cache.Trashnode_modules,build,dist,target,*.log5. Configure SOPS Secrets
6. Implement Email Notifications
Port notification system from NixOS:
msmtp7. Update Host Configurations
Import backup module in Darwin hosts:
../../darwin/backupsto imports inhosts/Madison/default.nix../../darwin/backupsto imports inhosts/Piper/default.nix../../darwin/backupsto imports inhosts/Catra/default.nixTechnical Challenges
1. launchd vs systemd
StartCalendarIntervalRandomizedDelaySecequivalent (may need wrapper script with random sleep)2. No systemd failure hooks
launchdKeepAlivewithSuccessfulExit = falsefor automatic retries3. Logging
systemd journal → macOS unified logging or custom log files
Use
StandardErrorPathandStandardOutPathin launchd configConsider using
loggercommand for syslog integrationNixOS uses
IdentityAgent noneVerify this works on Darwin or adjust as needed
Acceptance Criteria
just checkandjust testpass with new configurationsudo restic-aws snapshotsand see snapshotssudo restic-sftp snapshotsand see snapshotsExpected Behavior
After implementation:
References
nixos/backups/client.nix:1-70nixos/backups/shared.nix:1-98nixos/backups/Morgan-restic-excludes.txt:1-85Notes
log show --predicate 'subsystem == "restic-backup-sftp"' --last 1h