Paperless Backup/Restore

The problem

When you have a paperless installation and keep all your documents only there, then it is crucial to have a proper backup strategy. You definitely have to follow the 3-2-1 backup strategy. That means you have the original data, one local backup and one remote backup.

My installation

I have a installation on Proxmox. It is setup using the the proxmox helper scripts from here: https://community-scripts.github.io/ProxmoxVE/scripts?id=paperless-ngx

I am using shared volumes from a Synology Storage with mount points at /export and /opt/paperless/media.

The Synology itself uses redundant disks and replicates the data also to another Synology.

Proxmox also creates backups of all VMs and Containers to a Proxmox Backup Server also running on that Synology as VM.

So overall, we already have good data redundancy. But we do not have a remote backup yet.

The solution

Backing up documents and databases

Paperless provides the backup solution, document-exporter. The description there is how it works and how to use it with docker-compose or on a bare metal installation. I had to search for some time to find out how that works in this Proxmox LXC Container.

There nothing like document-exporter that you can call. Here it is a subcommand of manage.py located in /opt/paperless/src.

So you can call it with

python3 manage.py document_exporter ....

when you are in that directory. How to use it and which options you have you can find in the link above. The simplest solution ist just call it like this:

python3 manage.py document_exporter /export --no-progress-bar --passphrase "my secret passphrase"
  • /export is the backup target
  • –no-progress-bar is helpful when it is used in a script
  • –passphrase will make sure that secret parts of the backup are encrypted.

With that we already have a full local backup. My solution to have a remote backup is Duplicati. There are also other options, such as Borg Backup and others. I decided for duplicate because I have an external running NextCloud and Duplicati has the option to backup to it using webdav.

Duplicati can be easily installed in the container by downloading the package (Debian) from the Duplicati website and then install it using apt:

apt -y install ./duplicati-2.1.0.5_stable_2025-03-04-linux-x64-gui.deb

I do not use the graphical interface at all but the cli:

duplicati-cli backup \
  "webdav://<nextcloud-url>/remote.php/dav/files/<nextcloud-user>/<backup-directory>/?auth-username=<nextcloud-user>&auth-password=<nextcloud-password>&use-ssl=true" \
  /export \
  --backup-name=<name of your choice> \
  --dbpath=/root/.config/duplicati/duplicati-export.sqlite \
  --encryption-module=aes \
  --compression-module=zip \
  --dblock-size=50mb \
  --passphrase=<your secret passphrase> \
  --retention-policy="7D:1D,1M:1W,6M:1M" \
  --auto-cleanup

This backs up the data in /export (before created with document_exporter) to the NextCloud. The data will be encrypted and compressed using the modules you select here. It will keep several versions depending on you retention policy and will deduplicate the data.

Restore/Recovery

Like the document-exporter, there is also a function document-importer. So for a disaster recovery you setup first your new paperless-ngx instance. Then restore the data from the Duplicati (or whatever you have used) backup. And the restore your data with:

python3 manage.py document_importer /export --no-progress-bar --passphrase "my secret passphrase"

This will restore your paperless data including users and configuration.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert