# Back up and restore self-hosted Truetask

Schedule automatic backups, take one by hand, download or delete archives, and restore a self-hosted Truetask instance from a backup.

URL: https://docs.truetask.io/self-hosted/backups

Self-hosted only.

Truetask backs up its PocketBase database on a schedule you set, keeps a bounded number of archives, and lets you download any of them.
The pane is **Settings > Server > Backups**, and only workspace owners and admins can open it.

![Truetask self-hosted Backups settings pane with schedule and archive list](https://docs.truetask.io/screenshots/settings-backups.webp)

## Backup health

The first thing in the pane is a **Last backup** row with the age of the newest archive as a status pill.

| Pill | Age |
| --- | --- |
| Green | Up to 26 hours old |
| Amber | Up to 72 hours old |
| Red | Older than 72 hours |
| Neutral | No backups yet |

A daily schedule keeps this green.
Amber means a run was missed.

## The schedule

**Automatic backups** is picked by name: Off, Every hour, Every day at 04:00, Every Monday at 04:00, or Custom cron expression.
The named rhythms are plain cron schedules underneath, and Custom shows the expression itself: five fields, minute, hour, day of month, month and weekday, with the usual `*`, `,`, `-` and `/`.
The pane checks a custom expression before it is saved, so a typo never becomes a schedule that silently never runs.

Off disables automatic backups.

**Keep** bounds how many automatic archives are retained.
The oldest ones are removed once the count is reached; manual archives are never touched.
Set it to `0` for unlimited.

A fresh instance ships with a daily backup at 04:00 keeping 7 archives, which the pane shows as Every day at 04:00.

> **The shipped schedule is reapplied at every start**
>
> The daily 04:00 schedule and the keep-7 limit are written by the instance at every container start.
> A custom schedule you save here does not survive a restart, so re-check this pane after an update or a reboot.

## Taking a backup by hand

**Create backup** takes one immediately.
It is named `manual_` plus the date and time, for example `manual_20260922143005.zip`.

From the command line:

```bash
scripts/management/truetask-backup.sh create
scripts/management/truetask-backup.sh list
```

The script reads the admin credentials out of `.env`, authenticates against the running instance, and triggers the backup through PocketBase's own API, so the stack has to be up.

> **One command, two archives**
>
> `truetask-backup.sh create` currently sends the create request twice and leaves two archives behind.
> Delete the spare from the pane, or use **Create backup** in the app instead.

`scripts/management/truetask-status.sh` prints how many archives exist and the name, size and age of the newest, without authenticating.

## The archive list

Every archive is listed with its **Name**, **Size** and **Date**, sortable by any of the three.
Each row has two actions.

**Download** streams the archive to your machine.
This is how you get a copy off the server.

**Delete** removes it, behind a confirmation dialog, because it cannot be undone.

## Where the archives live

By default they are written to `backups/` inside `pb_data` in your data directory, so `<DATA_DIR>/pb_data/backups/`.

If you configure **Backup storage** in [S3 storage](https://docs.truetask.io/self-hosted/s3-storage), archives go to your bucket instead.
The pane keeps working the same way: the list, the download and the delete all read that bucket.
If the bucket is unreachable the list comes back empty rather than erroring, so an empty list on an instance you know has backups is a sign to check the S3 settings.

> **Get them off the machine**
>
> A backup sitting next to the database it protects does not survive a dead disk.
> Either point Backup storage at a bucket, or copy `<DATA_DIR>/pb_data/backups/` somewhere else on a schedule of your own.

## What a backup holds, and what it does not

The archive is written by PocketBase from its own data directory, so it carries the database and the files PocketBase stores locally.

Three things are outside it:

- Uploaded files, when **File storage** points at an S3 bucket.
  Those live in the bucket and have to be backed up there.
- The installed plugins, in `<DATA_DIR>/plugins`.
  The archive records which plugins are installed but not their files, so copy that folder with it.
  A restore without it marks each plugin **Failed**, saying its version is not on the plugins volume, until you install the archive again.
- Your `.env`, including `PB_ENCRYPTION_KEY` and the VAPID keys.
  The setup wizard keeps a copy at `<DATA_DIR>/.env`, which is still on the same machine.
  Store the real copy with your other secrets.

> **The encryption key is part of the backup**
>
> If `PB_ENCRYPTION_KEY` is set, the sensitive settings inside the archive are encrypted with it.
> Restoring that archive onto an instance with a different key leaves those settings unreadable, and they have to be entered again.
> Restore the key and the data together.

## Restoring

There is no restore button in Truetask.
Restoring is a file operation with the stack stopped.

1. Stop the stack.

   ```bash
   scripts/management/truetask-stop.sh
   ```

2. Move the current data aside rather than deleting it, so you can go back if the restore is wrong.

   ```bash
   mv <DATA_DIR>/pb_data <DATA_DIR>/pb_data.before-restore
   ```

3. Unpack the archive into a fresh `pb_data` at the same path.

4. Make sure the files are owned by UID 1000, which is what PocketBase runs as inside the container.

   ```bash
   chown -R 1000:1000 <DATA_DIR>/pb_data
   ```

5. Put back `<DATA_DIR>/plugins` from the same moment, if you use plugins.

6. Confirm `.env` still carries the `PB_ENCRYPTION_KEY` that was in use when the archive was written.

7. Start the stack.

   ```bash
   scripts/management/truetask-start.sh
   ```

PocketBase runs its migrations on the way up.
If the archive came from an older version, running a newer image over it migrates it forward, which is the direction that works.
Going the other way needs the matching old image; see [Updates](https://docs.truetask.io/self-hosted/updates).

## Exporting instead

A backup is a database archive, not a portable file.
If what you want is your content in a form you can read elsewhere, use **Settings > Server > Export**, which produces a ZIP of boards, tasks, lists, tags, users, comments, checklists, time entries, workflows, custom fields, folders and attachments.
See [Exporting](https://docs.truetask.io/import-export/exporting).

## Related

- [S3 storage](https://docs.truetask.io/self-hosted/s3-storage)
- [Updates](https://docs.truetask.io/self-hosted/updates)
- [Data retention](https://docs.truetask.io/self-hosted/data-retention)
- [Security](https://docs.truetask.io/self-hosted/security)
