Skip to content

Backups & restore

LabPod backs up its SQLite database - workspaces, users, workspace templates, policies, audit logs, and settings. Scheduled and manual snapshots protect only the database. Research files, workspace homes, workspace definitions, template build contexts, and installation configuration live outside it; back them up separately with your host-level backup tool. See What database snapshots do not cover.

For the saved recipe and settings format, see Workspace definition files.

The install script registers labpod-backup.timer, which runs once a day with a randomized delay and calls:

Terminal window
labpod admin backup --retention 14

This creates a timestamped snapshot (labpod-YYYYMMDDTHHMMSSZ.db) and keeps the 14 most recent, pruning older ones. By default it uses /var/lib/labpod/backups; set LABPOD_BACKUP_DIR in /etc/labpod/labpod.env to move both scheduled backups and installer recovery artifacts together.

Terminal window
# Inspect the timer
sudo systemctl list-timers labpod-backup.timer
# Check recent backup logs
sudo journalctl -u labpod-backup.service --since today
# List existing backups
ls -lah /var/lib/labpod/backups/
Terminal window
# Run these as root
# Inspect the timer
systemctl list-timers labpod-backup.timer
# Check recent backup logs
journalctl -u labpod-backup.service --since today
# List existing backups
ls -lah /var/lib/labpod/backups/

Force a snapshot now:

Terminal window
sudo systemctl start labpod-backup.service
Terminal window
# Run these as root
systemctl start labpod-backup.service

Set a directory in the environment file and create it as root:

Terminal window
(
set -euo pipefail
sudoedit /etc/labpod/labpod.env
# Add or change: LABPOD_BACKUP_DIR=/srv/labpod/backups
sudo install -d -m 0750 /srv/labpod/backups
)
Terminal window
# Run these as root
(
set -euo pipefail
${EDITOR:-vi} /etc/labpod/labpod.env
# Add or change: LABPOD_BACKUP_DIR=/srv/labpod/backups
install -d -m 0750 /srv/labpod/backups
)

labpod-backup.service runs under a ProtectSystem=strict sandbox that only allows writes to the paths listed in its unit’s ReadWritePaths. Editing LABPOD_BACKUP_DIR alone does not update that list, so relocating the directory (or tuning retention) needs a drop-in:

Terminal window
sudo systemctl edit labpod-backup.service
Terminal window
# Run these as root
systemctl edit labpod-backup.service

In the editor, paste:

[Service]
ExecStart=
ExecStart=/usr/local/bin/labpod admin backup --retention 30
ReadWritePaths=/var/lib/labpod /srv/labpod/backups

Drop the ReadWritePaths line if you’re only tuning retention and keeping the default directory.

Terminal window
(
set -euo pipefail
sudo systemctl daemon-reload
sudo systemctl restart labpod-backup.timer
)
Terminal window
# Run these as root
(
set -euo pipefail
systemctl daemon-reload
systemctl restart labpod-backup.timer
)

Write a self-contained snapshot to an explicit path:

Terminal window
sudo labpod admin --db /var/lib/labpod/labpod.db backup --out /tmp/labpod-adhoc.db
Terminal window
# Run these as root
labpod admin --db /var/lib/labpod/labpod.db backup --out /tmp/labpod-adhoc.db

This fails fast if the database file doesn’t exist (no silent empty-DB creation).

Restore requires stopping the service because SQLite refuses a hot copy when the WAL sidecar (.db-wal, .db-shm) is in use.

Terminal window
(
set -euo pipefail
snapshot="/var/lib/labpod/backups/labpod-20260517T030000Z.db"
sudo test -f "$snapshot"
sudo test -s "$snapshot"
sudo systemctl stop labpod
sudo labpod admin --db /var/lib/labpod/labpod.db restore \
"$snapshot"
sudo systemctl start labpod
)
Terminal window
# Run these as root
(
set -euo pipefail
snapshot="/var/lib/labpod/backups/labpod-20260517T030000Z.db"
test -f "$snapshot"
test -s "$snapshot"
systemctl stop labpod
labpod admin --db /var/lib/labpod/labpod.db restore \
"$snapshot"
systemctl start labpod
)

restore will prompt for confirmation unless you pass --yes.

The backup is a complete snapshot of the LabPod database:

  • Users, roles, and hashed passwords
  • Workspace records, start history, and GPU allocations
  • Workspace templates and their port/env configuration
  • Resource policies and system settings
  • Session records and audit logs
  • Usage samples and rollups

Not included: anything outside the database file, listed below. Running state - kernels, unsaved notebooks, training progress since the last checkpoint - is never captured.

Back up these file sets separately, preferably to storage independent of the LabPod host, and regularly test restoring them together with a database snapshot taken at the same time:

WhatDefault location
Research and work files (notebooks, datasets, checkpoints, environments)<passwd-home>/work, or <LABPOD_WORK_BASE>/<user>/work when configured
Persistent workspace homes, including archives of deleted workspaces<passwd-home>/workspaces/
Workspace definitions (each workspace’s saved recipe and settings)<passwd-home>/.config/labpod/workspaces/
Editable workspace-template build contexts<user-work>/.labpod/context/
Imported workspace-template contexts/var/lib/labpod/builds/template-imports/
Installation configuration/etc/labpod/ (including labpod.env), systemd units and drop-ins, TLS and license files

Container images can usually be downloaded again from their registry or rebuilt from a saved recipe; keep your own copy of any image you could not reproduce. Writable container layers are not backed up: Stop removes them, so save anything valuable to /work or the workspace home first.

The installer’s pre-upgrade-* recovery sets in the backup directory are a separate mechanism. Each one keeps the previous executable, application files, and a paired database snapshot for upgrade rollback (see Upgrades). They are not part of the daily rotation and do not replace configuration or workspace-data backups.

Recovering workspaces needs the database and the file sets above from one quiet point in time. To make such a set:

  1. Arrange a maintenance window. Owners save notebooks and checkpoints and stop their workspaces (root can force-stop); finish or cancel image builds and pending creates.
  2. Stop the backup timer, wait for a running backup to finish, then stop LabPod.
  3. Take a database snapshot, then copy the file sets while preserving numeric ownership, permissions, hard links, ACLs, and extended attributes (for example with rsync -aHAX --numeric-ids). Record checksums and store the set off the host.
  4. Start LabPod and the backup timer again.
Terminal window
(
set -euo pipefail
sudo systemctl stop labpod-backup.timer
state=$(systemctl is-active labpod-backup.service) || [ "$?" -eq 3 ]
[ "$state" = inactive ]
sudo systemctl stop labpod
sudo labpod admin --db /var/lib/labpod/labpod.db backup --out /mnt/recovery/labpod-set/labpod.db
)
Terminal window
# Run these as root
(
set -euo pipefail
systemctl stop labpod-backup.timer
state=$(systemctl is-active labpod-backup.service) || [ "$?" -eq 3 ]
[ "$state" = inactive ]
systemctl stop labpod
labpod admin --db /var/lib/labpod/labpod.db backup --out /mnt/recovery/labpod-set/labpod.db
)

To restore, first recreate the Linux accounts with the same numeric UID/GID, groups, and HOME. Restore the files to their recorded locations without merging them into existing data, restore the database with labpod admin restore, then start LabPod. Each owner then reviews their workspace settings, explicitly downloads or builds the image if needed, and starts the workspace. A recovered workspace starts as a fresh container from its saved files; it does not resume old processes. Rehearse the procedure on an isolated host before relying on it.