initial commit
This commit is contained in:
29
scripts/backup.sh
Normal file
29
scripts/backup.sh
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Exit immediately if a command exits with a non-zero status
|
||||
set -e
|
||||
|
||||
BACKUP_DIR="./backups"
|
||||
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
|
||||
DB_BACKUP_FILE="${BACKUP_DIR}/penpot_db_${TIMESTAMP}.sql"
|
||||
ASSETS_BACKUP_FILE="${BACKUP_DIR}/penpot_assets_${TIMESTAMP}.tar.gz"
|
||||
|
||||
echo "=== Starting Penpot Backup ($TIMESTAMP) ==="
|
||||
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
|
||||
# Backup PostgreSQL Database
|
||||
echo "Backing up Database..."
|
||||
docker compose exec -T penpot-postgres pg_dump -U penpot -d penpot -c > "$DB_BACKUP_FILE"
|
||||
echo "Database backed up to $DB_BACKUP_FILE"
|
||||
|
||||
# Backup Assets Volume
|
||||
echo "Backing up Assets..."
|
||||
docker compose run --rm \
|
||||
-v $(pwd)/backups:/backups \
|
||||
penpot-backend \
|
||||
tar czvf /backups/penpot_assets_${TIMESTAMP}.tar.gz -C /opt/data/assets .
|
||||
|
||||
echo "Assets backed up to $ASSETS_BACKUP_FILE"
|
||||
|
||||
echo "=== Backup Complete! ==="
|
||||
51
scripts/restore.sh
Normal file
51
scripts/restore.sh
Normal 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! ==="
|
||||
12
scripts/update.sh
Normal file
12
scripts/update.sh
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Pulling latest Penpot images..."
|
||||
docker compose pull
|
||||
|
||||
echo "Recreating containers..."
|
||||
docker compose up -d
|
||||
|
||||
echo "Removing old unused images..."
|
||||
docker image prune -f
|
||||
|
||||
echo "Penpot update complete!"
|
||||
Reference in New Issue
Block a user