Skip to content

feat(backup): nightly encrypted export of neo's RouterOS config - #1710

Merged
Gerrrt merged 2 commits into
mainfrom
gerrrt/neo-config-backup
Nov 24, 2026
Merged

Gerrrt merged 2 commits into
mainfrom
gerrrt/neo-config-backup

Conversation

@Gerrrt

@Gerrrt Gerrrt commented Nov 24, 2026

Copy link
Copy Markdown
Owner

What changed

neo's configuration is now backed up every night. scripts/backup-firewall.sh gains a BACKUP_DEVICE=switch profile, run by make backup-switch. It:

  • logs in as a new read-only user backup on neo, through morpheus;
  • takes /export;
  • reuses the firewall export's existing steps without change: encrypt to the same age recipients, verify, copy to oracle, and keep thirty on each side.

homelab-backup-switch.timer runs it daily at 09:45.

  • The switch's settings use the SW_* prefix (SW_KEEP, SW_OFFHOST, SW_HOST, SW_USER, SW_JUMP). They never read FW_*, so an override meant for the firewall in /etc/default/homelab-timers can't move the switch's exports.
  • The .sops.yaml catch-all rule now also covers backups/switch/, and check_sops_rules.py checks that path.
  • install-timers.sh gets a backup-switch row with a 3-day staleness threshold, the same as backup-firewall.
  • swap-the-switch.md gets a restore section. It lists the four things the export leaves out: users, the certificate, the SNMPv3 passphrases and device-mode.
  • network.md, schedule-maintenance.md, both READMEs and the changelog are updated.

Why

A re-check after the switch audit found that neo's configuration existed only on the switch. If neo died, it would have to be rebuilt by hand from network.md and the wiki's port map.

Blast radius

  • neo: has one new user, backup. Its group has read and ssh only, its address is limited to 10.7.7.1/32, and it logs in with prometheus's key only, because RouterOS refuses a password for a user that has a key. A test write as backup was refused with not enough permissions.

  • The firewall export: its path is unchanged. Both self-tests pass, and the recipient lookup still reads the same rule.

  • Not offsite: backup-offsite.sh doesn't carry the switch export. A fire that destroys both prometheus and oracle also destroys the switch, and its rebuild is documented.

  • No change to network segmentation or firewall rules

  • No new port published to a VLAN that could not already reach the service

  • No credential added outside secrets/*.sops.yaml (a public key on the switch, no secret)

Verification

  • A test run, BACKUP_DEVICE=switch ./scripts/backup-firewall.sh --local-only from a worktree, printed verified config-…sops.yaml — RouterOS 7.24.6, 7 input filter rules. The file was encrypted to both recipients. I then deleted it.

  • The plaintext export contains no password=, passphrase or private-key line.

  • --self-test passes for both devices.

  • shellcheck, check_sops_rules.py, check_docs.py, lint.sh and install-timers.sh --check pass.

  • The full run with the copy to oracle and the timer install happen from the deployed checkout after merge.

  • make validate passes (running; result in a comment)

  • Deployed to the lab and confirmed working (after merge)

  • Docs updated (docs/, service README, or docs/roadmap.md)

🤖 Generated with Claude Code

Copilot AI balanced review requested due to automatic review settings November 24, 2026 04:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved issues allow incomplete backups to pass verification and make recovery steps fail, while exposing decrypted configuration and leaving the default administrator enabled.

6 open issues
What changed in this PR

Adds nightly encrypted backups of neo’s RouterOS configuration by reusing the existing firewall backup pipeline, with separate switch settings and recovery instructions.

Changes:

  • Adds a switch profile that exports, encrypts, verifies, copies to oracle, and retains configuration backups.
  • Schedules the backup at 09:45 with job monitoring and a three-day staleness threshold.
  • Extends encryption-policy checks and documents backup coverage and restoration.
File Description
systemd/​README.md Lists the switch backup schedule.
systemd/​homelab-backup-switch.timer Schedules the daily 09:45 backup.
systemd/​homelab-backup-switch.service Runs the monitored switch backup job.
scripts/​README.md Documents the shared device-backup script.
scripts/​install-timers.sh Registers the switch job and staleness threshold.
scripts/​check_sops_rules.py Checks encryption-policy coverage for switch exports.
scripts/​backup-firewall.sh Adds switch-specific export settings and verification.
Makefile Adds the backup-switch target.
docs/​runbooks/​swap-the-switch.md Adds export recovery and restoration instructions.
docs/​runbooks/​schedule-maintenance.md Documents scheduling and backup monitoring.
docs/​network.md Records the backup account and export destinations.
docs/​changelog.md Records the new switch backup capability.
.sops.yaml Extends the shared encryption rule to switch backups.

Review effort: Balanced

Comment thread docs/runbooks/swap-the-switch.md Resolved
Comment thread docs/runbooks/swap-the-switch.md Resolved
Comment thread docs/runbooks/swap-the-switch.md Resolved
Comment thread docs/runbooks/swap-the-switch.md Resolved
Comment thread docs/runbooks/swap-the-switch.md Resolved
Comment thread scripts/backup-firewall.sh Resolved
@Gerrrt
Gerrrt enabled auto-merge (squash) November 24, 2026 04:55
Gerrrt and others added 2 commits November 24, 2026 05:44
neo's configuration lived only on the switch. backup-firewall.sh gains a
BACKUP_DEVICE=switch profile (make backup-switch): it logs in as a
read-only `backup` user through morpheus, takes /export, and reuses the
firewall export's encrypt, verify, copy-to-oracle and retention unchanged.
The switch's knobs are SW_*, so a firewall override in the shared
environment file cannot move its exports. homelab-backup-switch.timer runs
it at 09:45; swap-the-switch.md gains the restore and what the export
leaves out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The export check now refuses an export with RouterOS's #error lines. The
restore makes the destination directory, decrypts with umask 077, imports
the certificate before the config, and disables the admin user a reset
brings back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Gerrrt
Gerrrt force-pushed the gerrrt/neo-config-backup branch from dc1bd6d to 0eaa611 Compare November 24, 2026 05:47
@Gerrrt
Gerrrt merged commit de4c8e8 into main Nov 24, 2026
9 checks passed
@Gerrrt
Gerrrt deleted the gerrrt/neo-config-backup branch November 24, 2026 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants