Dxcufgb's Workshop

How a Backup Works

WIPWork in progress: may be very buggy and can change a lot between versions.

  1. The world folder is checked: is it readable, and, through Foundry's /api/status, is the world active.
  2. git add -A in the world folder with the git directory in STATE_DIR/repos/<id> (GIT_DIR and GIT_WORK_TREE; nothing is written into the world folder), then a commit when anything changed (Backup of <title> (<id>) <time>, author Foundry world backup). Nothing changed = no commit, still a success. With github.releases on, the commit also holds .github/workflows/release-world.yml, put into git's index only (marked skip-worktree so git add -A keeps it); the world folder never gets the file. Off removes it again.
  3. The repository is looked up on GitHub: created (private) when missing and createRepos is on. A repository the token cannot push to, or that is outside the token's account and missing, is an error.
  4. git push of HEAD to the repository's main branch. The token reaches git only through a credential helper in the environment of that one git process: it is never on a command line, in a URL, in a log line, in a commit or in status.json.
  5. status.json is updated and, on a failure, an e-mail is sent; the first success after a failure sends an "OK again" e-mail. See Notifications and Daily Check.

Queue and restarts

One world is backed up at a time. "Back up now" queues a world that is not already running or queued.

A world whose backup is running when the service restarts is retried on its next slot (its lastScheduled is only set when the run started, so a missed slot shows up as due).

When backups run

The schedule is set on the admin page's Schedule page or per world; see Configuration Reference for the options. A slot missed while the machine was off runs as soon as the service is back, so a freshly installed service backs every world up once right away.

This page mirrors the World Backup to Git wiki on GitHub.