initial commit

This commit is contained in:
2026-03-17 19:33:46 +08:00
commit aa90835d84
8 changed files with 266 additions and 0 deletions

51
scripts/restore.sh Normal file
View File

@@ -0,0 +1,51 @@
#!/bin/bash
# Exit immediately if a command exits with a non-zero status
set -e
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <path_to_db_backup.sql> <path_to_assets_backup.tar.gz>"
echo "Example: $0 backups/penpot_db_20231026_120000.sql backups/penpot_assets_20231026_120000.tar.gz"
exit 1
fi
DB_FILE=$1
ASSETS_FILE=$2
# Verify files exist
if [ ! -f "$DB_FILE" ]; then
echo "Error: Database backup file '$DB_FILE' not found."
exit 1
fi
if [ ! -f "$ASSETS_FILE" ]; then
echo "Error: Assets backup file '$ASSETS_FILE' not found."
exit 1
fi
echo "=== Starting Penpot Restore ==="
echo "Stopping frontend, backend, and exporter..."
docker compose stop penpot-frontend penpot-backend penpot-exporter
echo "Restoring Database from $DB_FILE..."
cat "$DB_FILE" | docker compose exec -T penpot-postgres psql -U penpot -d penpot
echo "Database restored."
# We spin up a temporary container, delete current assets, and extract the backup
# Convert relative path of ASSETS_FILE to absolute path for the volume mount
echo "Restoring Assets from $ASSETS_FILE..."
ABS_ASSETS_FILE=$(realpath "$ASSETS_FILE")
ABS_ASSETS_DIR=$(dirname "$ABS_ASSETS_FILE")
ASSETS_FILENAME=$(basename "$ABS_ASSETS_FILE")
docker compose run --rm \
-v "$ABS_ASSETS_DIR":/backups \
penpot-backend \
sh -c "rm -rf /opt/data/assets/* && tar xzvf /backups/$ASSETS_FILENAME -C /opt/data/assets/"
echo "Assets restored."
echo "Restarting all Penpot services..."
docker compose start
echo "=== Restore Complete! ==="