# Backups

The wiki and IRC bot both create automatic backups of character sheets before making changes. No character data is ever silently lost.

## How Backups Work

### Wiki Backups

Every time a character sheet is saved through the wiki (edit, approval, restore), the wiki creates a timestamped backup of the **current** file before overwriting it.

### Bot Backups

The IRC bot creates **one backup per character per day** -- before the first edit of that character on a given day. Subsequent bot edits on the same day do not create additional backups.

This means if an ST runs several `!set` or `!damage` commands during a session, only the pre-session state is backed up. This keeps the backup directory manageable while still preserving the state before any changes were made.

## Backup Storage

Backups are stored in:
```
_characters/_backups/<slug>/<timestamp>.toml
```

The timestamp format is `2006-01-02T15-04-05` (UTC, sortable). Example:
```
_characters/_backups/storm-runner/
  2026-02-15T03-22-41.toml
  2026-02-16T08-45-12.toml
  2026-02-17T22-01-30.toml
```

## Viewing Character History

Admins can view a character's backup history through the wiki:

1. Navigate to the character's page
2. Click "History" or "Versions"
3. See a list of all backups with timestamps
4. Click any backup to view that version

## Comparing Versions

The wiki provides a **side-by-side diff view** to compare two versions of a character:

1. From the history page, select two versions to compare
2. The diff view highlights what changed between them
3. Changed fields are color-coded: {green}additions{/green}, {red}removals{/red}

This is especially useful for reviewing player submissions -- the pending review page automatically shows a diff between the submitted version and the current live version.

## Restoring from Backup

To restore a character to a previous state:

1. Go to the character's history
2. Find the backup you want to restore
3. Click "Restore"
4. The wiki creates a backup of the *current* state first, then restores the selected version

Restoring is non-destructive -- you can always restore back to the version before the restore.

## Downloading Backups

Any backup version can be downloaded as a TOML file:

1. From the character's history page
2. Click the download link next to any version
3. The file downloads as `<slug>-<timestamp>.toml`

## Retention

Backups are kept **indefinitely**. There is no automatic cleanup or rotation. For a typical game with a handful of characters and weekly sessions, backup storage growth is negligible.

## What's Not Backed Up

- **Wiki pages** -- not automatically backed up (use git for versioning)
- **Images** -- uploaded assets are not backed up
- **User accounts** -- stored in SQLite, not backed up by the wiki

If git integration is enabled (`git.enabled: true` in config), wiki page edits are auto-committed to a local git repository, providing version history for all page content.
