Security & Privacy

Paperless-ngx Backup: A Complete Guide

J
James Eriksson
··12 min read
Learn how to backup Paperless-ngx with document_exporter, incremental rsync, and cloud storage. Test restores, automate with cron, and follow 3-2-1 backup rules.
TL;DR
  • Use document_exporter to create portable backups that survive version upgrades and database corruption
  • Run incremental backups with the -c flag and rsync to minimize storage and transfer time
  • Test restores into a separate Paperless instance before you need the backup
  • Automate backups with cron jobs and store copies on external disks, NAS, and cloud storage following the 3-2-1 rule
  • Self-hosted backups require ongoing automation; evaluate whether managed Paperless-ngx hosting fits your team

Paperless-ngx stores your scanned documents in a database with metadata, full-text search indexes, and file storage. Without a backup, losing your server means losing your entire document archive. This guide covers every backup method available, from document exports to incremental snapshots, plus how to test a restore before you need it.

Why Backups Matter: The Risk of No Backup

Paperless-ngx is built on a SQLite or PostgreSQL database that holds document metadata, tags, correspondents, and full-text search data. The /data/media directory stores the actual scanned PDFs. If your server fails, gets corrupted, or you accidentally delete the container without volumes, both are gone. No metadata export. No scans. Nothing.

Most self-hosted setups run Paperless on a single machine. That machine is a single point of failure. A disk failure, ransomware, failed update, or hardware death means your entire document archive is gone unless you have a backup sitting somewhere else.

Managed hosting providers handle this for you, but if you run Paperless yourself, the responsibility is yours. The good news: Paperless-ngx has multiple backup methods built in, and they take 15 minutes to set up.

The official Paperless-ngx documentation recommends document_exporter as the primary backup method. It's the safest, most portable backup format because it exports everything as self-contained files and metadata that survive version upgrades and even database changes.

Here's how it works: document_exporter reads your database and media files and exports them into a directory with this structure:

export/
  documents/
    1_original.pdf
    1_archive.pdf
  metadata.json
  manifest.json

Every document is exported as a file. All metadata is stored in JSON files. If your database ever corrupts or you upgrade Paperless-ngx and something breaks, you can restore from this export into a fresh instance using document_importer.

To run a full backup, execute this command inside your Paperless container:

docker compose exec -T webserver document_exporter../export

The -T flag disables pseudo-TTY allocation, which is essential for scripts and cron jobs. Without it, the command hangs waiting for a terminal. The export directory is created automatically in your Paperless data folder.

You can add options to control what gets exported:

  • -d or --document-type exports only specific document types
  • -c or --compare-checksums skips re-exporting documents that haven't changed (incremental export)
  • -z or --compression compresses the output with gzip
  • -T or --thumbnail includes document thumbnails in the export
  • --passphrase encrypts the export with a password

For a full initial backup, most people run:

docker compose exec -T webserver document_exporter../export -z -T

This exports everything with compression and thumbnails. The file size typically shrinks to 30-50% of the original with gzip compression.

The first export takes the longest because it processes every document. On a 10,000-document archive, expect 5-20 minutes depending on disk speed. Subsequent backups with the -c flag only export changed documents, reducing time to seconds or minutes.

Alternative Backup Methods: Volumes and Database Backups

Document exporter is recommended, but it's not your only option. If you want simplicity over portability, Docker volume backups or database-specific backups also work.

Docker Volume Backups

If you're running Paperless with Docker Compose, your data is stored in named volumes. You can backup the entire volume:

docker run --rm -v paperless_data:/data -v /path/to/backup:/backup alpine tar czf /backup/paperless-data.tar.gz /data

This creates a tar.gz archive of your entire Paperless data directory, including the database and all media files. It's fast and simple, but it's a binary backup: you can't selectively restore a single document, and version incompatibilities might make it unreadable in a future Paperless version.

Database-Specific Backups

If you're using PostgreSQL instead of SQLite, you can back up just the database:

docker compose exec -T db pg_dump -U paperless paperless_db > paperless_db.sql

This creates a SQL file that can be restored into any PostgreSQL instance. However, this only backs up the database, not the media files. You still need to separately backup /data/media.

For MariaDB:

docker compose exec -T db mysqldump -u paperless -p'password' paperless_db > paperless_db.sql

Comparison

MethodSpeedPortabilityIncrementalEncryption
Document ExporterSlow (first run)Excellent (JSON/files)Yes (-c flag)Yes (--passphrase)
Volume BackupFastPoor (binary)NoExternal tool
Database BackupFastMedium (SQL only)NoExternal tool

For most people, document_exporter wins because it's recoverable even after major upgrades, and the -c flag makes incremental backups practical.

Incremental Backups with Rsync

Full backups are safe, but they're wasteful. If you're backing up 50GB of documents every week, you're wasting storage and bandwidth. Rsync lets you sync only the files that changed since the last backup.

After running an initial full document export, set up incremental backups with rsync:

rsync -av --delete /path/to/export/ /mnt/backup/paperless-export/

This syncs only the files that changed. The --delete flag removes files from the backup if they've been deleted from Paperless. On subsequent runs, rsync transfers only deltas, taking seconds or minutes instead of an hour.

To combine this with document_exporter in a backup script:

#!/bin/bash
set -e

# Run incremental export
docker compose exec -T webserver document_exporter../export -c -z

# Rsync to backup destination
rsync -av --delete /data/export/ /mnt/backup/paperless-export/

# Log the backup
echo "Backup completed: $(date)" >> /var/log/paperless_backup.log

The -c flag in document_exporter makes this efficient: only documents with changed checksums are re-exported, keeping the rsync delta minimal.

Testing Your Restore: Before Disaster Strikes

A backup is useless if you can't restore from it. The only way to know your backup works is to restore it into a test instance and verify the data is intact.

Here's a restore procedure using a Docker Compose stack on the same server:

  1. Create a test instance of Paperless-ngx with its own volumes:
cd /tmp
mkdir paperless_restore_test
cd paperless_restore_test

# Copy your docker-compose.yml and.env files here

# Edit.env to change PAPERLESS_ADMIN_PASSWORD and PAPERLESS_SECRET_KEY
docker compose up -d
  1. Wait for the test instance to initialize (1-2 minutes):
docker compose logs -f webserver | grep "Listening on"
  1. Create an admin user in the test instance:
docker compose exec -T webserver createsuperuser
  1. Run document_importer to restore from your backup:
docker compose exec -T webserver document_importer../backup/export/

Substitute../backup/export/ with the path to your document_exporter export directory.

  1. Wait for the import to complete (time depends on document count; 5-10 minutes for 10,000 documents).

  2. Access the test instance using your configured port and verify:

    • Document count matches the original
    • Random documents open and display correctly
    • Search finds documents
    • Tags and correspondents are intact
    • Full-text OCR is searchable
  3. If everything looks good, your backup is valid. Tear down the test instance:

docker compose down -v

Common restore errors:

  • "database is locked": document_importer is running on the same database as your production instance. Use a separate test instance.
  • "version mismatch": The export was created by a different Paperless version than the restore instance. Update the restore instance to match.
  • Missing media files: The export path contains only metadata. Run the import command with the full backup directory, not just metadata files.

Automating Backups with Cron and Scripts

Manual backups are better than nothing, but automated backups are better than manual ones. Set up a cron job to run backups on a schedule.

Create a backup script at /home/paperless/backup.sh:

#!/bin/bash
set -e

BACKUP_DIR="/mnt/backup/paperless"
EXPORT_DIR="/data/export"
LOG_FILE="/var/log/paperless_backup.log"

echo "Starting backup: $(date)" >> $LOG_FILE

cd /home/paperless/docker-compose

# Run incremental export
docker compose exec -T webserver document_exporter../export -c -z -T 2>> $LOG_FILE

# Verify export succeeded
if [ ! -f "$EXPORT_DIR/manifest.json" ]; then
  echo "ERROR: Export failed, manifest.json not found" >> $LOG_FILE
  exit 1
fi

# Rsync to backup location
rsync -av --delete "$EXPORT_DIR/" "$BACKUP_DIR/" >> $LOG_FILE 2>&1

# Keep only the last 4 backups
find $BACKUP_DIR -maxdepth 1 -type d -name "backup-*" -mtime +30 -exec rm -rf {} \;

echo "Backup completed: $(date)" >> $LOG_FILE

Make it executable:

chmod +x /home/paperless/backup.sh

Add a cron job to run daily at 2 AM:

crontab -e

Add this line:

0 2 * * * /home/paperless/backup.sh

Monitor the logs:

tail -f /var/log/paperless_backup.log

For alerting, add a simple health check: if the backup hasn't run in 48 hours, send an alert. This catches silent failures (cron disabled, permissions changed, disk full).

Storage Strategies: Where to Keep Your Backups

Backups on the same server as your Paperless instance are not backups. If the server burns down, your backups burn with it. Follow the 3-2-1 backup rule: 3 copies of your data, on 2 different media types, with 1 offsite.

Local Storage (External Disk)

Connect an external USB drive or eSATA disk to your Paperless server and mount it at /mnt/backup. Backups are fast (local disk speed, typically 50-200 MB/s). Recovery is instant. But the drive is still vulnerable to theft or hardware failure.

Use this for recent, quick-access backups. Rotate the drive offsite weekly.

Network Attached Storage (NAS)

If you have a Synology, QNAP, or other NAS, back up over your local network via SMB or NFS:

sudo mount -t nfs 192.168.1.100:/export/paperless /mnt/nas_backup
rsync -av --delete /data/export/ /mnt/nas_backup/

Backups are fast (gigabit network is usually 50-100 MB/s). The NAS is a separate device, so if your Paperless server fails, the backup survives. But if your house burns down, both devices burn.

Use this for your 3-2-1 "media type 2" copy.

Cloud Storage (AWS S3, Google Drive, OneDrive)

Cloud backups are offsite, so they survive physical disasters. But they're slower and cost money.

AWS S3:

aws s3 sync /data/export/ s3://my-paperless-backup/

Costs: typically $0.023 per GB stored (S3 Standard) + $0.0004 per upload request. A 50GB backup costs about $1.15/month.

Backblaze B2:

Similar to S3 but cheaper: $0.006 per GB ($0.30/month for 50GB) + $0.004 per 10,000 upload requests.

Google Drive or OneDrive:

If you already have a family plan, these are free. Upload speed is limited to 500 KB/s on free accounts, so backups take longer. But for a 50GB archive, one overnight backup is acceptable.

Storage Comparison

MethodSpeedCostOffsiteRecovery Time
External USB50-200 MB/s$20-50 (one-time)ManualInstant
NAS (SMB/NFS)50-100 MB/s$200-500 (device)NoInstant
AWS S310-50 MB/s$0.30/monthYesInstant
Backblaze B210-50 MB/s$0.30/monthYesInstant
Google Drive0.5 MB/sFree (if owned)YesInstant

For a small household or freelancer: use local external disk weekly + cloud (Backblaze B2 or similar) monthly.

For a small firm handling sensitive documents: local NAS daily + cloud offsite weekly.

When Self-Hosted Backups Aren't Enough

If you're managing backups manually, you have all the responsibility. No notifications if backups fail. No redundancy if the external drive gets stolen. No offsite copy if you forget to rotate the drive.

Most small firms eventually move to managed hosting because the operational burden outweighs the cost savings. At that point, backups become the provider's responsibility. Opsily's managed Paperless-ngx hosting includes daily automated backups, geographic redundancy, and geographic distribution across EU data centers. You don't have to think about document_exporter commands, rsync scripts, or recovery testing.

If you value your time and your document archive, evaluate whether self-hosting is worth the operational overhead.

Frequently Asked Questions

How do I back up Paperless-ngx?

The recommended method is document_exporter. Run docker compose exec -T webserver document_exporter../export -c -z to create an incremental, compressed export of all documents and metadata. For subsequent backups, the -c flag skips documents that haven't changed, making incremental exports fast.

What is the difference between document_exporter and volume backups?

document_exporter creates portable JSON and file exports that work across versions. Volume backups are binary snapshots of your entire data directory. document_exporter is recommended because it survives Paperless upgrades and version mismatches; volume backups may become unreadable after major updates.

How do I restore from a Paperless-ngx backup?

Create a test instance of Paperless-ngx, place your document_exporter export in the data directory, and run docker compose exec -T webserver document_importer../export. Wait for import to complete, then verify document counts, search, and tags match the original instance.

Can I backup Paperless-ngx to cloud storage?

Yes. After exporting with document_exporter, use rsync to sync to cloud storage (AWS S3, Backblaze B2, Google Drive). Most cloud services offer 0.5-50 MB/s upload speed depending on your internet connection. For a 50GB archive, full uploads take 24-100 hours; use incremental exports (-c flag) for faster subsequent backups.

How do I automate Paperless-ngx backups?

Create a bash script that runs document_exporter, then rsync, and schedule it with cron. Example: 0 2 * * * /home/paperless/backup.sh runs backups daily at 2 AM. Monitor logs to catch failures before you need the backup.

How do I test a Paperless-ngx restore?

Deploy a second Paperless instance with its own volumes (Docker Compose makes this easy). Import your backup export into the test instance and verify document counts, search functionality, and metadata are intact. Tear down the test instance after validation.

What happens if my Paperless-ngx database gets corrupted?

If SQLite becomes corrupted, the database is unreadable and you must restore from backup. This is why document_exporter is crucial: it exports everything to portable files before the database can fail. If you only backup Docker volumes, a corrupted database backup is useless.

The Bottom Line

Paperless-ngx stores documents and metadata in a database that can fail. Without backups, you lose everything. document_exporter is the safest backup method because it's portable, testable, and survives version upgrades. Set up automated backups with cron, test a restore into a throwaway instance to verify integrity, and keep copies on external disks and cloud storage to follow the 3-2-1 rule. If managing backups feels like operational overhead, Opsily's managed Paperless-ngx hosting removes the responsibility.

Backups made simple
Opsily handles daily automated backups, geographic redundancy, and restore testing for managed Paperless-ngx.
Get Started Free

Ready to self-host your own apps?

One server. Multiple apps. No per-app fees.

Get started →
Paperless-ngx Backup: Complete Step-by-Step Guide