Last active
August 6, 2025 10:42
-
-
Save k4mrul/1d379c95f577e4082be4f75c7fce5a71 to your computer and use it in GitHub Desktop.
Restore wordpress (uploads directory) and db (for flywp)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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