How to backup docmost on docker [noob] #272
Replies: 3 comments 2 replies
-
|
duplicati |
Beta Was this translation helpful? Give feedback.
-
|
its very strange. If i add a line, after doing a file level backup. (shut down docmost, redis and db) then delete the db and redis directory. If i delete a page and restore the backup, this works great. the page is back. But very strange, the line which i added after the backup and before the page delete, its also back... What is this a strange behavior ? |
Beta Was this translation helpful? Give feedback.
-
|
Hello, Backupdocmost.docker-compse.yml ---
services:
docmost:
image: docmost/docmost:0.24.1
depends_on:
- db
- redis
environment:
APP_URL: ${APP_URL}
APP_SECRET: ${APP_SECRET}
DATABASE_URL: ${DATABASE_URL}
REDIS_URL: ${REDIS_URL}
MAIL_DRIVER: ${MAIL_DRIVER}
SMTP_HOST: ${SMTP_HOST}
SMTP_PORT: ${SMTP_PORT}
SMTP_USERNAME: ${SMTP_USERNAME}
SMTP_PASSWORD: ${SMTP_PASSWORD}
MAIL_FROM_NAME: ${MAIL_FROM_NAME}
MAIL_FROM_ADDRESS: ${MAIL_FROM_ADDRESS}
SMTP_SECURE: ${SMTP_SECURE}
ports:
- "3333:3000"
restart: unless-stopped
volumes:
- docmost:/app/data/storage
labels:
docker-volume-backup.stop-during-backup: true
db:
image: postgres:16-alpine
environment:
POSTGRES_DB: ${POSTGRES_DB}
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
restart: unless-stopped
volumes:
- db_data:/var/lib/postgresql/data
- db_dumps:/tmp/dumps
healthcheck:
test: pg_isready -U docmost
interval: 10s
timeout: 5s
retries: 3
labels:
docker-volume-backup.archive-pre: >-
/bin/sh -c 'export PGPASSWORD=${POSTGRES_PASSWORD} &&
pg_dump -U ${POSTGRES_USER} -f /tmp/dumps/${POSTGRES_DB}.dump
-Fc ${POSTGRES_DB}'
redis:
image: redis:7.2-alpine
restart: unless-stopped
volumes:
- redis_data:/data
backup:
image: offen/docker-volume-backup:v2
environment:
BACKUP_CRON_EXPRESSION: ${BACKUP_CRON_EXPRESSION}
BACKUP_FILENAME: >-
docmost_backup_%Y%m%d_%H%M%S.tar.gz
BACKUP_COMPRESSION: ${BACKUP_COMPRESSION}
BACKUP_ARCHIVE: "/archive"
BACKUP_PRUNING_PREFIX: docmost_backup_
EXEC_FORWARD_OUTPUT: "true"
AWS_ENDPOINT: ${AWS_ENDPOINT}
AWS_S3_BUCKET_NAME: ${AWS_S3_BUCKET_NAME}
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
AWS_S3_PATH: ${AWS_S3_PATH}
volumes:
- backups:/archive
- db_data:/backup/db_data:ro
- docmost:/backup/docmost:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
restart: unless-stopped
volumes:
docmost:
db_data:
redis_data:
db_dumps:
backups:Restoredocmost.restore.sh #!/bin/bash
# Docmost Database Restore Script
# Usage: ./restore.sh <filebase_url>
#
# This script restores a Docmost backup by:
# 1. Downloading backup from Filebase
# 2. Extracting the backup archive
# 3. Restoring the PostgreSQL database
# 4. Cleaning up temporary files
# 5. Restarting services
if [ -z "$1" ]; then
echo "Usage: ./restore.sh <filebase_url>"
echo "Example: ./restore.sh https://diplomatic-coffee-dinosaur.myfilebase.com/ipfs/QmNmKwfJgyn3poJqdzQ8G4yVo2j3H7WLGaTDymzbb1MDcx"
exit 1
fi
FILEBASE_URL="$1"
BACKUP_FILE="/tmp/docmost_restore.tar.gz"
# Load environment variables from .env
if [ -f ".env" ]; then
source .env
fi
DB_CONTAINER_NAME="docmost-db-1"
DOCMOST_CONTAINER_NAME="docmost-docmost-1"
DB_NAME="${POSTGRES_DB:-docmost}"
DB_USER="${POSTGRES_USER:-docmost}"
echo "Downloading backup from Filebase..."
if ! wget -O "$BACKUP_FILE" "$FILEBASE_URL"; then
echo "✗ Failed to download backup from: $FILEBASE_URL"
exit 1
fi
if [ ! -f "$BACKUP_FILE" ]; then
echo "✗ Backup file not found after download: $BACKUP_FILE"
exit 1
fi
echo "This will restore the Docmost database. Continue? (y/n)"
read -r response
if [ "$response" != "y" ]; then
echo "Restore cancelled"
exit 0
fi
echo "Extracting backup..."
TEMP_DIR="/tmp"
tar -xzf "$BACKUP_FILE" -C "$TEMP_DIR"
echo "Restoring database..."
docker exec -i "$DB_CONTAINER_NAME" pg_restore -U "$DB_USER" -d "$DB_NAME" -c --if-exists < "$TEMP_DIR/backup/db_dumps/docmost.dump"
echo "Restoring Docmost storage..."
DOCMOST_RESTORE_PATH="/tmp/backup/docmost"
docker cp "$DOCMOST_RESTORE_PATH/." "$DOCMOST_CONTAINER_NAME:/app/data/storage/"
echo "Restarting services..."
docker compose down
docker compose up -d
echo "Cleaning up temporary backup file..."
rm -f "$BACKUP_FILE"
echo "✓ Restore complete"Happy coding |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
what would be the recommended way to backup and restore docmost on Docker?
For a backup to be fully functional, my understanding is that I would need to backup:
-database (default name: docmost-db-1)
-files. E.G. videos, images attached to the docmost pages (stored in the "docmost_docmost" volume).
Is my understanding correct?
As a test I tried:
docker exec -i pg_container_name /bin/bash -c "PGPASSWORD=pg_password pg_dump --username pg_username database_name" > /desired/path/on/your/machine/dump.sqldocker exec -i pg_container_name /bin/bash -c "PGPASSWORD=pg_password psql --username pg_username database_name" < /path/on/your/machine/dump.sqlI would have expected the page to reappear. But nothing changed on docmost, to the point that I am thinking that either the dump or the restore (or both failed).
What would be a solid procedure for backing up?
I don't have experience with Docker and self-hosting but I can fiddle with command line and did manage to install docmost on docker (although the credit goes to the installation guide, which made it really easy).
Thank you very much for any pointers.
Beta Was this translation helpful? Give feedback.
All reactions