Skip to main content

Back up an OpenProject (package install) to a NAS

The packaged OpenProject (DEB/RPM) has its own backup command. It writes a database dump plus archives of attachments, configuration and repositories.

Run the built-in backup

sudo openproject run backup
ls /var/db/openproject/backup/
# a database dump (*.pgdump) plus *.tar.gz archives for attachments, config and repositories

Copy it off the server and tidy up

#!/bin/bash
set -euo pipefail
SRC=/var/db/openproject/backup
DST=/mnt/backup/$(hostname -s)/openproject
mountpoint -q /mnt/backup
openproject run backup
mkdir -p "$DST"
rsync -a "$SRC"/ "$DST"/
find "$DST" -type f -mtime +7 -delete
# Clean the local copies too, including the big attachment archives
find "$SRC" -type f \( -name '*.pgdump' -o -name '*.tar.gz' \) -mtime +1 -delete

Make sure the local clean-up includes the *.tar.gz files. Otherwise the attachment archives build up in /var/db until the disk is full.

How often?

A full backup includes every attachment, so daily is usually right:

0 2 * * * root /usr/local/bin/backup_openproject.sh >/dev/null 2>&1

Restore

Follow the OpenProject documentation for "Restoring an installation". In short: stop the services, restore the .pgdump with pg_restore, unpack the attachments and configuration archives, then run openproject configure.