Replies: 7 comments
-
My server dumps all of its databases into compressed .sql files every day. An incremental offsite backup runs every morning. Nothing fancy. |
Beta Was this translation helpful? Give feedback.
-
Everythibg is running on my Synology. |
Beta Was this translation helpful? Give feedback.
-
I run the following script every night which leverages restic to store an incremental backup on my Synology NAS. The backup path is included in my Synology HyperBackup configuration, thus distributed to my backup NAS and to an online storage (in my case Hetzner Storage Box) on a daily basis. #!/usr/bin/env bash
#
# Backup Paperless-ngx
#
PATH=/usr/local/bin:$PATH
# https://stackoverflow.com/questions/242538/unix-shell-script-find-out-which-directory-the-script-file-resides
SCRIPT_PATH=$(readlink -f "$0")
BASE_DIR=$(dirname "$SCRIPT_PATH")
RESTIC_PASSWORD=$(grep -oP "RESTIC_PASSWORD=\K.+" "${BASE_DIR}/.env")
if [ -z "$RESTIC_PASSWORD" ]; then
echo "\$RESTIC_PASSWORD is required"
exit 1
fi
COMPOSE_PROJECT_NAME=$(grep -oP "COMPOSE_PROJECT_NAME=\K.+" "${BASE_DIR}/.env")
if [ -z "$COMPOSE_PROJECT_NAME" ]; then
echo "\$COMPOSE_PROJECT_NAME is required"
exit 1
fi
COMPOSE_DIR=/volume1/docker/$COMPOSE_PROJECT_NAME
BACKUP_DIR=/volume1/backup/$COMPOSE_PROJECT_NAME
mkdir -p $BACKUP_DIR
mkdir -p $BACKUP_DIR/config
# Export Paperless-ngx
cd $COMPOSE_DIR
sudo docker-compose exec -T app document_exporter ../export -d -f -p
sudo cp -R .env docker-compose.yml backup.sh README.md config/ $BACKUP_DIR/config
PAPERLESS_VERSION=$(cat data/app/export/version.json | jq -r '.version')
# Backup exported files with restic to local storage
# (which in turn will be backed up by Synology HyperBackup to my other NAS as well as online storage once a day)
cd $BACKUP_DIR
if [[ ! -f "restic/config" ]] ; then
sudo docker run -e RESTIC_PASSWORD=$RESTIC_PASSWORD -v $(pwd):$(pwd) -w $(pwd) ghcr.io/restic/restic --repo restic init
fi
# https://forum.restic.net/t/not-finding-a-parent-snapshot-after-container-running-restic-exits/5066/7
# https://forum.restic.net/t/restic-never-finds-a-parent-snapshot-when-the-snapshot-exists/4312
sudo docker run --rm -h $HOSTNAME -e RESTIC_PASSWORD=$RESTIC_PASSWORD -v $COMPOSE_DIR/data/app/export:/export:ro -v $BACKUP_DIR/config:/config:ro -v $(pwd):$(pwd) -w $(pwd) ghcr.io/restic/restic --repo restic backup --tag paperless-ngx --tag v$PAPERLESS_VERSION --ignore-inode /export /config
# Delete old snapshots
# https://restic.readthedocs.io/en/stable/060_forget.html
# TODO: keep last x daily, x weekly, x monthly backups?
sudo docker run --rm -h $HOSTNAME -e RESTIC_PASSWORD=$RESTIC_PASSWORD -v $COMPOSE_DIR/data/app/export:/export:ro -v $(pwd):$(pwd) -w $(pwd) ghcr.io/restic/restic --repo restic forget --keep-last 10 --prune |
Beta Was this translation helpful? Give feedback.
-
Keep in mind the document importer only works with exports from the same version. So basically its really suitable for backups with sufficient time inbetween. |
Beta Was this translation helpful? Give feedback.
-
I have multi User and want to give each User a backup of their files (incase they shredded the paper source and need the PDFs) So i just copy/rsync /var/lib/docker/volumes/paperless_media .. /User1 to a Samaba share of User1 a Export of complete paperless to a (external) USB is on my todo / pile of shame |
Beta Was this translation helpful? Give feedback.
-
I use this small bash script that uses document exporter and gzips all files to later on transport it with the nightly backup. #!/bin/bash
# Define the directory for paperless-ngx export
EXPORT_DIR="./export"
# Empty the export directory before starting
echo "Emptying existing export..."
rm -rf "$EXPORT_DIR/*"
# Run the paperless-ngx export command
echo "Exporting data..."
docker-compose exec -T webserver document_exporter ../export
# Check for successful export (optional)
if [ $? -eq 0 ]; then
echo "Export complete."
else
echo "Error during export. Please check logs."
exit 1
fi
# Create a timestamped archive of the export directory
ARCHIVE_NAME="paperless-ngx_backup_$(date +%Y-%m-%d_%H-%M-%S).tar.gz"
echo "Creating archive: $ARCHIVE_NAME"
tar -czf "$ARCHIVE_NAME" "$EXPORT_DIR"
echo "Backup completed successfully!" |
Beta Was this translation helpful? Give feedback.
-
I just run everything on VMs. |
Beta Was this translation helpful? Give feedback.
-
Hi,
since reinstalling paperless-ngx on a ubuntu install (docker) on Proxmox, I stupidly deleted my old workflow for backups, which was as follows:
Once the instance is started:
That worked quite well, although I never managed to get more export info into my log mail.
Since I hate doing stuff I already did once again and I am also curious how others handle such a use case: How do you keep your paperless data backed up in case anything happens to the device you're running it on?
Beta Was this translation helpful? Give feedback.
All reactions