rewrites the whole thing

This commit is contained in:
Jean-Christophe Vanhalle
2023-08-14 14:48:47 +02:00
parent 222d86a909
commit b47876ad62
19 changed files with 407 additions and 139 deletions

51
pull-remote-db.sh Executable file
View File

@@ -0,0 +1,51 @@
#! /bin/sh
#
echo "ne fonctionne pas encore comme je veux, à ré-écrire pour docker, ne fonctionne que si accès ssh à un machine (ne marche pas avec un conteneur), ne fonctionnera pas à partir d'un conteneur sans clé SSH, doit avoir wp installé localement, etc."
echo "en attendant: faire un dump de la remote db and utiliser replace-db et migrate-db"
exit 0
set -a
. "${PWD}/.env"
set +a
mkdir --parents "${PWD}/tmp"
FILENAME="${REMOTE_ARCHIVE_TMP_NAME_PREFIX}".$(date +%Y-%m-%d-%H-%M-%S).sql
wp \
migratedb \
export "/tmp/${FILENAME}.gz" \
--find="//${REMOTE_WP_URL},${REMOTE_WP_PATH}" \
--gzip-file \
--path="${REMOTE_WP_PATH}" \
--replace="//${WP_URL},/var/www/html" \
--skip-replace-guids \
--ssh="${REMOTE_SSH_STRING}"
if ! scp "${REMOTE_SSH_STRING}:/tmp/${FILENAME}.gz" "${PWD}/tmp"; then
echo "couldn't get remote db"
exit 1
fi
gunzip "${PWD}/tmp/${FILENAME}.gz"
docker compose up db -d
while ! docker ps -q -f name="${PREFIX}-db"; do
echo "Waiting for the db container to be up and running..."
sleep 1
done
while ! docker exec "${PREFIX}-db" /bin/sh -c "mysqladmin ping -h 127.0.0.1 -P 3306 --protocol=tcp -u root -p${DB_ROOT_PASSWORD} --silent"; do
echo "Waiting for the mysql server in ${PREFIX}-db to be up and running..."
sleep 1
done
FILENAME=sitefederalnextmove01_vpn_ecolo_be.2023-08-11-16-14-43.sql
docker cp "${PWD}/tmp/${FILENAME}" "${PREFIX}"-db:/tmp
echo "dropping ${DB_NAME}"
docker exec "${PREFIX}-db" /bin/sh -c "mysqladmin --force -uroot -p${DB_ROOT_PASSWORD} drop ${DB_NAME}"
echo "creating ${DB_NAME}"
docker exec "${PREFIX}-db" /bin/sh -c "mysqladmin -uroot -p${DB_ROOT_PASSWORD} create ${DB_NAME}"
echo "importing ${PWD}/tmp/${FILENAME} (/tmp/${FILENAME}) into ${DB_NAME}"
docker exec "${PREFIX}-db" /bin/sh -c "mysql -uroot -p${DB_ROOT_PASSWORD} ${DB_NAME} < /tmp/${FILENAME}"