url issue mysql restore fix

This commit is contained in:
Jay Sharma
2023-08-22 19:04:50 +05:30
parent 23f236a437
commit dad1893851

View File

@@ -128,19 +128,17 @@ kubectl cp $FILE $NAMESPACE/common-job-pod:/tmp/$FILE
#Create schema if not present #
# -------------------------------
kubectl exec common-job-pod -n $NAMESPACE -- sh -c '. /tmp/setenv.sh; mysql -h $DB_HOST --user=$DB_USER --password=$DB_PASSWORD -e "create schema IF NOT EXISTS $SUBDOMAIN"'
kubectl exec common-job-pod -n $NAMESPACE -- sh -c '. /tmp/setenv.sh; export FILE=`ls /tmp/*.sql.gz` ; gunzip -c $FILE | mysql -h $DB_HOST --user=$DB_USER --password=$DB_PASSWORD $SUBDOMAIN'
kubectl exec common-job-pod -n $NAMESPACE -- sh -c 'wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar ; chmod u+x wp-cli.phar;mv wp-cli.phar /usr/local/bin/wp; php /usr/local/bin/wp --info'
kubectl exec common-job-pod -n $NAMESPACE -- sh -c '. /tmp/setenv.sh; OLD_URL=`wp option get siteurl --allow-root --path=/usr/share/nginx/subdomain/$SUBDOMAIN`; echo "export OLD_URL=$OLD_URL" >> /tmp/setenv.sh; echo "export FIND=$(echo $OLD_URL|cut -d. -f2,3)" >> /tmp/setenv.sh; echo "export OLD_URL_DOMAIN=$(echo $OLD_URL| cut -d/ -f3)" >> /tmp/setenv.sh '
kubectl exec common-job-pod -n $NAMESPACE -- sh -c '. /tmp/setenv.sh; wp search-replace --allow-root --path=/usr/share/nginx/subdomain/$SUBDOMAIN "$OLD_URL" "$NEW_URL" --all-tables'
kubectl exec common-job-pod -n $NAMESPACE -- sh -c '. /tmp/setenv.sh; wp search-replace --allow-root --path=/usr/share/nginx/subdomain/$SUBDOMAIN "$OLD_URL_DOMAIN" "$URL_DOMAIN" --all-tables ; . /tmp/setenv.sh; wp search-replace --allow-root --path=/usr/share/nginx/subdomain/$SUBDOMAIN "$FIND" "$REPLACE" --all-tables'
kubectl exec common-job-pod -n $NAMESPACE -- sh -c '. /tmp/setenv.sh; wp search-replace --allow-root --path=/usr/share/nginx/subdomain/$SUBDOMAIN "$FIND" "$REPLACE" --all-tables; . /tmp/setenv.sh; wp search-replace --allow-root --path=/usr/share/nginx/subdomain/$SUBDOMAIN "$OLD_URL_DOMAIN" "$URL_DOMAIN" --all-tables'
kubectl exec common-job-pod -n $NAMESPACE -- sh -c '. /tmp/setenv.sh; wp search-replace --allow-root --path=/usr/share/nginx/subdomain/$SUBDOMAIN "http://$URL_DOMAIN" "$NEW_URL" --all-tables'
kubectl delete po common-job-pod -n $NAMESPACE
cat script.log | grep -v -i warning | egrep -i "fail|exception|error|unexpected|cannot access|No such file" && exit 9 || echo VALIDATION_PASS_$opt
;;
wp-data-restore)