Last active
August 6, 2025 10:42
-
-
Save k4mrul/bb3abeb2b7d4db49a0c035b07791d24b to your computer and use it in GitHub Desktop.
Backup 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 | |
tar -czvf "${DOMAIN//./-}-uploads.tar.gz" -C "$DOMAIN/app/public/wp-content/uploads" . | |
# Export the database using WP-CLI inside the correct container | |
CONTAINER_NAME="${DOMAIN//./}-php-1" | |
docker exec "$CONTAINER_NAME" wp db export /tmp/backup.sql | |
docker cp "$CONTAINER_NAME":/tmp/backup.sql "${DOMAIN//./-}-backup.sql" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment