Skip to content

Instantly share code, notes, and snippets.

@k4mrul
Last active August 6, 2025 10:42
Show Gist options
  • Save k4mrul/1d379c95f577e4082be4f75c7fce5a71 to your computer and use it in GitHub Desktop.
Save k4mrul/1d379c95f577e4082be4f75c7fce5a71 to your computer and use it in GitHub Desktop.
Restore wordpress (uploads directory) and db (for flywp)
#!/bin/bash
# Parse command-line arguments
for ARG in "$@"; do
case $ARG in
--domain=*)
DOMAIN="${ARG#*=}"
;;
*)
echo "Unknown argument: $ARG"; exit 1
;;
esac
done
if [ -z "$DOMAIN" ]; then
echo "Usage: $0 --domain=DOMAIN"
exit 1
fi
rm -rf "$DOMAIN/app/public/wp-content/uploads/*"
# Extract the site files
tar -xzvf "${DOMAIN//./-}-uploads.tar.gz" -C "$DOMAIN/app/public/wp-content/uploads"
# Restore the database using WP-CLI inside the correct container
CONTAINER_NAME="${DOMAIN//./}-php-1"
docker cp "${DOMAIN//./-}-backup.sql" "$CONTAINER_NAME":/tmp/backup.sql
docker exec "$CONTAINER_NAME" wp db import /tmp/backup.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment