2023-01-17 20:16:50 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Stop on Error
|
|
|
|
set -e
|
|
|
|
|
2025-05-10 02:09:06 +02:00
|
|
|
# Configure those to match your PLANKA Docker container names
|
|
|
|
PLANKA_DOCKER_CONTAINER_POSTGRES="planka-postgres-1"
|
|
|
|
PLANKA_DOCKER_CONTAINER_PLANKA="planka-planka-1"
|
2023-01-17 20:16:50 +01:00
|
|
|
|
|
|
|
# Extract tgz archive
|
|
|
|
PLANKA_BACKUP_ARCHIVE_TGZ=$1
|
2024-11-27 11:49:55 +01:00
|
|
|
PLANKA_BACKUP_ARCHIVE=$(basename "$PLANKA_BACKUP_ARCHIVE_TGZ" .tgz)
|
2023-01-17 20:16:50 +01:00
|
|
|
echo -n "Extracting tarball $PLANKA_BACKUP_ARCHIVE_TGZ ... "
|
2024-11-27 11:49:55 +01:00
|
|
|
tar -xzf "$PLANKA_BACKUP_ARCHIVE_TGZ"
|
2023-01-17 20:16:50 +01:00
|
|
|
echo "Success!"
|
|
|
|
|
|
|
|
# Import Database
|
|
|
|
echo -n "Importing postgres database ... "
|
2024-11-27 11:49:55 +01:00
|
|
|
cat "$PLANKA_BACKUP_ARCHIVE/postgres.sql" | docker exec -i "$PLANKA_DOCKER_CONTAINER_POSTGRES" psql -U postgres
|
2023-01-17 20:16:50 +01:00
|
|
|
echo "Success!"
|
|
|
|
|
|
|
|
# Restore Docker Volumes
|
2025-05-10 02:09:06 +02:00
|
|
|
echo -n "Importing favicons ... "
|
|
|
|
docker run --rm --volumes-from "$PLANKA_DOCKER_CONTAINER_PLANKA" -v "$(pwd)/$PLANKA_BACKUP_ARCHIVE:/backup" ubuntu cp -rf /backup/favicons /app/public/
|
|
|
|
echo "Success!"
|
2023-01-17 20:16:50 +01:00
|
|
|
echo -n "Importing user-avatars ... "
|
2024-11-27 11:49:55 +01:00
|
|
|
docker run --rm --volumes-from "$PLANKA_DOCKER_CONTAINER_PLANKA" -v "$(pwd)/$PLANKA_BACKUP_ARCHIVE:/backup" ubuntu cp -rf /backup/user-avatars /app/public/
|
2023-01-17 20:16:50 +01:00
|
|
|
echo "Success!"
|
2025-05-10 02:09:06 +02:00
|
|
|
echo -n "Importing background-images ... "
|
|
|
|
docker run --rm --volumes-from "$PLANKA_DOCKER_CONTAINER_PLANKA" -v "$(pwd)/$PLANKA_BACKUP_ARCHIVE:/backup" ubuntu cp -rf /backup/background-images /app/public/
|
2023-01-17 20:16:50 +01:00
|
|
|
echo "Success!"
|
|
|
|
echo -n "Importing attachments ... "
|
2024-11-27 11:49:55 +01:00
|
|
|
docker run --rm --volumes-from "$PLANKA_DOCKER_CONTAINER_PLANKA" -v "$(pwd)/$PLANKA_BACKUP_ARCHIVE:/backup" ubuntu cp -rf /backup/attachments /app/private/
|
2023-01-17 20:16:50 +01:00
|
|
|
echo "Success!"
|
|
|
|
|
|
|
|
echo -n "Cleaning up temporary files and folders ... "
|
2024-11-27 11:49:55 +01:00
|
|
|
rm -r "$PLANKA_BACKUP_ARCHIVE"
|
2023-01-17 20:16:50 +01:00
|
|
|
echo "Success!"
|
|
|
|
|
|
|
|
echo "Restore complete!"
|