Skip to content

Migrating a Docker XNAT

dbeasley1 edited this page Oct 3, 2023 · 2 revisions

XNAT 1.8

In Development!!!

You can save XNAT - the containers and shared storage. This is useful for backing up. It creates a folder ./backup which contains saved containers stored as .tar files and also a compressed copy of the mounted directories.

In order to work with Linux, the postgresql folder cannot be mounted - before starting you must edit some files:

docker-compose-template:
         line 27, 71 - remove #WIN#, so /pg_backup will be mounted:
              - @POSTGRES_PATH@/postgres-data:/pg_backup
         delete lines 95,50:
              #LINX- @POSTGRES_PATH@/postgres-data:/var/lib/postgresql/data

./xnat/templates/cronjobs.txt:
         delete #WIN# - 

The cronjob makes a regular backup of the database to @POSTGRES_PATH@/postgres-data rather than mounting the actual database. When XNAT is restarted, this database backup is restored.

To save/backup XNAT:

cd [path_to]/xnat-setup/Linux/

sudo ./save_and_restore.sh save

To restore XNAT from the backup directory:

First create a docker secret on the new server. This contains the password for the Postgresql server. To create type:

echo "[POSTGRESQL PASSWORD]" | docker secret create pgpass -

replacing [POSTGRESQL PASSWORD] with the actual password. The run:

sudo ./save_and_restore.sh restore

Clone this wiki locally