Upstream/deploy/upstream-backup.service
jvanvik 249818a7aa Stage 3-5 server (military, expansion, social), web client for stages 1-2, ops/deploy
Built: units/research/training, movements (scan, raid, attack, takeover, reinforce, settle, transport), deterministic
combat resolved in the event queue, reports, power/offline units, founding + conquest + incumbent sites; alliances,
roles, diplomacy (24h pact cancel via events), messages, rankings; vanilla-JS phone-first client (auth, POP, map,
alerts, settings, en/nb); systemd units, backup timer, DEPLOY.md, tools/admin.js.
Tested: npm test 96/96 (fake clock, in-memory db, a few real-HTTP tests); client checked with headless Chromium
screenshots only. NOT done: marketplace/transport trade, client screens for military/social, WebSocket push,
bots/balance, e2e suite. All unit stats and costs are unbalanced first guesses.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q2MJaQ5LXAHzGnTDgceT14
2026-10-11 18:32:36 +02:00

40 lines
1.7 KiB
Desktop File

# One database snapshot (VACUUM INTO, verified, dated file name, old ones pruned). Started by upstream-backup.timer,
# or by hand: systemctl start upstream-backup. Safe while the game server is running (SQLite WAL: readers do not block
# the writer). See docs/DEPLOY.md, "Backups".
#
# install -m 0644 deploy/upstream-backup.service deploy/upstream-backup.timer /etc/systemd/system/
# systemctl daemon-reload && systemctl enable --now upstream-backup.timer
[Unit]
Description=Upstream - database snapshot
Documentation=file:///opt/upstream/docs/DEPLOY.md
# Not started from the main unit's dependency graph: a backup must also work while the game is stopped.
[Service]
Type=oneshot
User=upstream
Group=upstream
WorkingDirectory=/opt/upstream
# Same state directory as upstream.service; snapshots go to /var/lib/upstream/backups (mode 0700).
StateDirectory=upstream
StateDirectoryMode=0700
# Same override file, so DB_PATH follows the main service if you changed it there.
EnvironmentFile=-/etc/upstream/upstream.env
Environment=DB_PATH=/var/lib/upstream/game.db
# Keep the newest 14 snapshots (daily timer = two weeks). Edit here, or `systemctl edit upstream-backup`.
# --keep-days D works too; with both, a snapshot survives if either rule keeps it.
ExecStart=/usr/bin/env node /opt/upstream/tools/admin.js backup /var/lib/upstream/backups --keep 14
# A failed snapshot (verification failed, disk full) must be visible: the unit fails and journalctl shows why.
TimeoutStartSec=15min
Nice=10
IOSchedulingClass=idle
NoNewPrivileges=yes
CapabilityBoundingSet=
AmbientCapabilities=
RestrictAddressFamilies=AF_UNIX
RestrictRealtime=yes
RestrictSUIDSGID=yes
LockPersonality=yes
SystemCallArchitectures=native
UMask=0077