Backing Up Space Docker


What is the recommended way of backing up Space running using the on-premise Docker image?

Thank you for your help.



Hi Pawel, in fact, there's nothing specific in the Space On-Premises installation in this regard, so feel free to stick to the approaches recommended by Docker:

1. Back up and restore volumes themselves:

2. Bind mounts to the host path and backup the host path itself:



I recommend Back up and restore volumes themselves. 

another way 'Bind mounts to the host path and backup the host path itself' is cause painful lfs-object uploading speed.


True...I would not use bind mounts either...but still there are many containers and lots of volumes to restore and backup.  I was hoping there was something simpler like a 'spacedump' as in 'mysqldump' to simplify backup and restore.


Pawel,  we're working on simplifying the backup and restore process for the Space installation and will share the results once ready. Talking about the DB in particular, you're right, the safest option would be using native means of PostgreSQL for this. In our case, it's a pg_dump command that results in a snapshot of the DB described as an SQL file. It can later be used to restore the DB from scratch.

I prepared a simple script that makes the process a bit easier. It allows using backup and restore commands, and takes 3 arguments in both cases:

  • `DB_CONTAINER_ID` is the ID of the postgres container. Can be acquired with the `docker ps` command.
  • `DB_USERNAME` is the `services.postgres.environment.POSTGRES_USER` value from the docker-compose.yml. By default it's `space`.
  • `DB_NAME` is the `services.postgres.environment.POSTGRES_DB` value from the docker-compose.yml. By default it's `spacedb`.


if [ $# -ne 4 ]; then
    # incorrect number of arguments
    echo "Not all arguments are specified. Usage: [backup|restore] [DB_CONTAINER_ID] [DB_USERNAME] [DB_NAME]"
    exit 1

case "$1" in
    echo "Running backup command..."
    docker exec -t $DB_CONTAINER_ID pg_dump -U $DB_USERNAME -d $DB_NAME > spacedb_dump.sql
    echo "Backup created"
    echo "Running restore command..."
    docker exec -i $DB_CONTAINER_ID psql -U $DB_USERNAME -d $DB_NAME < spacedb_dump.sql
    echo "Restore completed"
    # invalid argument
    echo "Invalid command. Usage: [backup|restore]"
    exit 1


The overall backup & restore process is as follows:

  1. execute ` backup [DB_CONTAINER_ID] [DB_USERNAME] [DB_NAME]`;
  2. stop the installation;
  3. assuming, there are no volumes with DB data anymore, start a DB container via `docker compose up postgres`;
  4. execute ` restore [DB_CONTAINER_ID] [DB_USERNAME] [DB_NAME]`;
  5. start the whole installation again with `docker compose up`.



Wow...thanks, Pavel, for sharing.  So this implies that everything is persisted in the Postgres database?  There is nothing else to backup, except for the conf directory in case it was generated locally when initially installing space?  Awesome...I am going to try and test this.  Thanks for sharing.


Pawel, sorry for not being clear: my previous alswer only covers the DB backup process. Space also utilizes Minio as object storage for git, packages and other binary entities. It should also be backed up after the DB backup is done.

Just as in the case of DB, I'd recommend using a native option provided by Minio:

The process is pretty similar, but I haven't had a chance to document it yet. In general, you need to install a Minio Client (mc) tool on the host machine, make an alias to your Minio instance with `mc alias ...` and then execute `mc mirror ...` for all buckets there.

The order of backups is important: 1. DB backup; 2. object storage backup. 



Please sign in to leave a comment.