Created
December 12, 2025 13:52
-
-
Save Staubgeborener/7ddbf7b036fdcc1ec9960e35279ee3c7 to your computer and use it in GitHub Desktop.
Paperless-ngx Backup with rclone
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Configure with "rclone config" before using this! | |
| #------------------------------------------------------- | |
| # Number of backups | |
| MAX_BACKUPS=30 | |
| # Backup to GoogleDrive, name the folder "paperless-ngx" | |
| REMOTE_PATH="GoogleDrive:paperless-ngx" | |
| # Docker container name of paperless-ngx | |
| CONTAINER="paperless-ngx" | |
| # Host path to paperless-ngx files | |
| PAPERLESS_HOST_PATH="/mnt/user/appdata/paperless-ngx" | |
| # Timestamp for backup name | |
| TIMESTAMP=$(date +%Y%m%d) | |
| #------------------------------------------------------- | |
| cd $PAPERLESS_HOST_PATH | |
| # Create backup | |
| docker exec $CONTAINER document_exporter ../export -f -d | |
| zip -r paperless-ngx_export_$TIMESTAMP.zip export | |
| # Upload | |
| rclone copy paperless-ngx_export_$TIMESTAMP.zip "$REMOTE_PATH" | |
| echo "Backup: paperless-ngx_export_$TIMESTAMP.zip" | |
| # Delete old backups | |
| rclone lsf "$REMOTE_PATH" --files-only | grep "^paperless-ngx_export_" | sort | head -n -$MAX_BACKUPS | while read file; do | |
| rclone delete "$REMOTE_PATH/$file" | |
| echo "Delete: $REMOTE_PATH/$file" | |
| done | |
| # Clean export folder | |
| rm -r $PAPERLESS_HOST_PATH/export/* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment