Back up, restore, and update
ReferenceUpdated
On this page
This page shows how to back up a self-hosted Kanroo Core, restore it on a new server, and update it to a new version. We tested every command on a fresh Docker Compose stack.
Run every command in the deploy folder of your Kanroo clone, the folder with your .env file.
The self-host steps in the
README set it up. Kanroo Cloud users need none of this.
What a backup contains
A complete backup has three parts. Take them at the same time and keep them together.
| Part | What it holds |
|---|---|
| Database dump | Organizations, members, boards, tasks, comments, Wiki pages, and every other record |
| Files | Attachments, avatars, logos, and Wiki images from the kanroo_storage volume |
.env file |
The secrets of your installation, for example BETTER_AUTH_SECRET and PUBLIC_HANDLE_KEY |
The dump does not contain the .env file. Restore with the same file: then sign-ins, public
member handles, and shared filter URLs keep working. Protect the copy like a password.
With STORAGE_DRIVER=s3, your files are in the bucket, not in the volume. Take a snapshot of
the bucket in the same window instead, or turn on bucket versioning.
You do not need the Caddy volumes. Caddy gets a new TLS certificate on its own.
Back up
Kanroo stops for the backup, so that no upload or change slips in between the database dump and the files. It stays stopped while the dump and the archive run.
-
Create a protected folder for the backup and one timestamp for all three files:
umask 077 mkdir -p ~/kanroo-backups STAMP=$(date -u +%Y%m%dT%H%M%SZ) -
Stop the app and the worker. PostgreSQL keeps running:
docker compose stop kanroo-app kanroo-worker -
Dump the database with the read-only backup role, and check that the dump can be read:
docker compose exec -T postgres sh -c 'PGPASSWORD="$DB_PASSWORD_BACKUP" exec pg_dump --host=127.0.0.1 --username kanroo_backup --dbname "$DB_NAME" --format=custom --no-owner --no-acl' > ~/kanroo-backups/kanroo-$STAMP.dump docker compose exec -T postgres pg_restore --list < ~/kanroo-backups/kanroo-$STAMP.dump > /dev/nullThe second command prints nothing when the dump is fine.
-
Archive the files and check the archive. Skip this step with S3:
docker compose run --rm -T --no-deps kanroo-app tar -czf - -C /var/lib/kanroo/storage . > ~/kanroo-backups/kanroo-files-$STAMP.tar.gz tar -tzf ~/kanroo-backups/kanroo-files-$STAMP.tar.gz > /dev/null -
Copy the
.envfile and start Kanroo again:cp .env ~/kanroo-backups/kanroo-$STAMP.env docker compose up -d --wait -
Copy the three files to another machine. A backup that stays only on the Kanroo host is lost together with the host.
Run the backup on a schedule, keep several old backups, and test a restore from time to time.
Restore
A restore replaces the database and the files of the installation with the backup. Use the
Kanroo version of the backup: the saved .env file names it in KANROO_IMAGE. You can update
afterwards.
-
On a new server, install Docker and run only the
git cloneandcdcommands of the self-host steps: the saved.envfile replaces your configuration, and the restore replaces the first start. Copy the three backup files to the server.On an existing installation, stop the app and the worker first:
docker compose stop kanroo-app kanroo-worker -
Put the saved
.envfile in place, and set the timestamp of the backup you restore:cp ~/kanroo-backups/kanroo-<timestamp>.env .env STAMP=<timestamp> -
Start PostgreSQL, replace the database with an empty one, and restore the dump. Both run as the PostgreSQL administrator
DB_USERfrom.env:docker compose up -d --wait postgres docker compose exec -T postgres sh -c 'dropdb --username "$DB_USER" --maintenance-db=postgres --force --if-exists "$DB_NAME" && createdb --username "$DB_USER" --maintenance-db=postgres "$DB_NAME"' docker compose exec -T postgres sh -c 'exec pg_restore --username "$DB_USER" --dbname "$DB_NAME" --exit-on-error --single-transaction --no-owner --no-acl' < ~/kanroo-backups/kanroo-$STAMP.dumpThe restore runs in one transaction: if it fails, the database stays empty.
-
Set up the database roles again. This gives the restored tables back to Kanroo’s own roles:
sh postgres/provision.sh -
Replace the files with the archive. Skip this step with S3, and restore the bucket snapshot instead:
docker compose run --rm -T --no-deps kanroo-app sh -c 'find /var/lib/kanroo/storage -mindepth 1 -delete && tar -xzf - -C /var/lib/kanroo/storage' < ~/kanroo-backups/kanroo-files-$STAMP.tar.gz -
Run the migrations, then start Kanroo. With the same version as the backup, the migrations change nothing:
docker compose run --rm kanroo-migrate docker compose up -d --wait
Then sign in, open a board and a Wiki page, and open an attachment.
The order matters: restore the dump into the empty database first, then set up the roles, then run the migrations.
Update
Kanroo publishes each release under its exact version number. The releases list them with their release notes.
-
Read the release notes of every version between your version and the new one.
-
Update the deployment files in your clone to the new release, for example with
git pull. -
In
.env, copy the value ofKANROO_IMAGEtoKANROO_PREVIOUS_IMAGE. Then setKANROO_IMAGEto the new version, for exampleghcr.io/kanroohq/kanroo:1.2.3. -
Update the database. If this fails, stop here: the old version keeps running.
docker compose run --rm kanroo-migrate -
Start the new version. Compose replaces the app and the worker:
docker compose up -d --wait docker compose psdocker compose psshows the new image forkanroo-appandkanroo-worker.
Keep the backup until the new version runs well. To go back, swap the values of KANROO_IMAGE
and KANROO_PREVIOUS_IMAGE in .env and run docker compose up -d --wait. This works only
while the release notes say that the database stays compatible. Otherwise, restore the backup
with the old version.
Good to know
- Never run
docker compose down -vor--volumeson a real installation. It deletes the database and the files. - PostgreSQL listens only on the Kanroo host. Run the backup there, not over the network.
- Server sizing, disk space for backups, and network access are on the page Self-hosting requirements.