nexus: enable linger so the backup timer runs unattended #3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "agent/nexus-backup-linger"
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
Enable systemd user lingering for the nexus operator so home-manager user timers run unattended. Sets
users.users.<user>.linger = trueon the nexus host. Without linger the systemd--usermanager runs only during an active login session, so the 03:00backup-forgejo.timernever fires when nobody is logged in.Refs vnprc/forgejo-config#5
Risk
R2 (low end). A single NixOS option on the existing operator user; reversible by a straight revert. Linger keeps the user manager alive across logout and boot, which is the intent. No secrets, no provisioning path, no persistent data touched.
Validation
nix evalofnixosConfigurations.nexus.config.users.users.<user>.linger, with this branch overridden intovnprc/deploy, returnstrue(wasnull/unmanaged on master).Follow-up
Reaches nexus after a
vnprc/deploylock bump plus a hostnixos-rebuild switch --flake ~/work/deploy#nexus(host-only). Pairs with vnprc/forgejo-config#6, which packages the backup tools onto$PATH; together they make the backup runnable from anywhere and running automatically.what are the security implications of this change? should we just automate backups on the forge server instead? this would skip a download -> upload step and prevent hypervisor network issues from interrupting backups. not to mention the hypervisor might be powered down at cron time.
Security implications of linger
Enabling linger grants no new privilege.
user@<uid>.servicestarts at boot instead of at first login and survives logout; units still run as the unprivileged operator user, with the same file permissions, no new capabilities, no new listening port, no sudo rule. Three things do change, in descending order of how much they matter:backup-forgejosshes toforge-vpsas root and torsync-net, both with~/.ssh/host(secrets/identity.nix). That key already sits on nexus unattended whether or not linger is on, and ssh never hands it to the far side, so linger changes when it is used, not what it can reach. If nexus is compromised, that key is the prize either way.~/.config/systemd/user/plus linger is a textbook non-root persistence foothold. It is not a real boundary here — the operator is inwheelon their own hypervisor, so anything that can write that directory already has a shorter path — but it is the honest delta./run/user/<uid>exists from boot. Immaterial.Worth more attention than linger itself: linger alone may not make the 03:00 run succeed. A systemd user service has no TTY, no ssh-agent and no askpass, so if
~/.ssh/hostcarries a passphrase, orforge-vps's host key is not already in the operator'sknown_hosts, the unattended run fails closed at the first ssh.notes/allod/forgejo-nixos-vps.mdrecords the current state as "automated timer has linger/SSH issues" — plural — so treat this PR as fixing one of two. Verify withjournalctl --user -u backup-forgejoafter a real unattended fire; a manualsystemctl --user startfrom a logged-in session can inherit session environment that the boot-time manager will not have.Should the backup just run on the forge server
Yes, and that decision is already on record.
notes/allod/forgejo-nixos-vps.mdtarget state: "Backup runs on the VPS itself (no linger, no laptop dependency)" and "nexusdrops thehomeModules.forgejoBackupimport (backup is server-side now)". It is Phase 4, gated behind migrating the VPS off Docker-on-Ubuntu to NixOS. All three of your arguments are in the plan's reasoning, and the network one is the strongest: the dump comes down overscp, which is not resumable, so a single home-link drop fails the whole run.Why it is sequenced after the migration rather than done now: on today's imperative Ubuntu box, VPS-side automation is a hand-installed cron job plus a key that no repo describes, so the machine stops being a function of its config (principles 8 and 9 — one source of truth, everything rebuilds from a clone). After the migration it is a declarative timer in
forgejo-config, which is also what makes that flake importable by strangers.What the move costs, and what Phase 4 has to do to pay for it:
~/.ssh/host: persecrets/identity.nixthat single key is root onforge-vps,nowhr-vpsandhashpool.dev,gitat the forge, and thersync-netlogin. Putting it on the most internet-exposed box in the stack collapses the entire set (principle 7 — per-purpose credentials bound any compromise to that machine's own access).~/.age/forgejo-backup.keyplus 1Password, so the offsite host still sees only ciphertext (principle 1 — own the root).backup.md, Disk Management). Dumping and then encrypting on that same disk roughly doubles peak residency; stream it, or keep the delete-immediately-after-transfer discipline the current script has.~/backups/forgejoon nexus, which is what makes a fast restore possible without the age key at hand. Either keep a nexus-side pull as a second consumer, or accept that every restore starts withrestore-forgejo --from-cloud.Recommendation
Merge this as the stopgap. It is three lines plus a comment, reverts cleanly, and it makes the current design do what it already claims: the timer is
OnCalendar=03:00withPersistent = true, so today a missed run waits for you to log in, and with linger it fires shortly after the next boot instead. That covers the powered-down-at-cron case inside the existing model at roughly zero cost, and it does not compete with Phase 4 — it expires into it.Then let Phase 4 delete it. The actionable next step there is the VPS survey and the NixOS migration, not a hand-rolled cron on the Ubuntu box; server-side backup is the reward for that migration, not a shortcut around it. Note that once Phase 4 lands, this line has no consumer left unless some other nexus user timer wants one, so revisit it then rather than keeping it on principle.
Neither design notifies anyone when the 03:00 run fails, on nexus or on the VPS. That gap outlives this PR and is probably the higher-value follow-up; say the word and I will open an issue for an
OnFailure=handler.Happy to hold this PR open until Phase 4 instead if you would rather not carry the stopgap.
c928cb8d38to46d5c1ed30