# 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