Created
April 28, 2020 16:06
-
-
Save Neshable/3cbb765815d0e6afc996eb8fa7a7cba8 to your computer and use it in GitHub Desktop.
WordPress Safe Update Through CLI
This file contains 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/sh | |
echo "Starting safe update" | |
# Display the WordPress version | |
current_wp_core=$(wp core version --path=./wordpress) | |
# Update the WordPress version | |
wp core update | |
wp core update-db | |
# Test website if it's ok | |
status_code=$(curl --write-out %{http_code} --silent --output /dev/null domain.com) | |
if [[ "$status_code" == 200 ]] ; then | |
echo "Website status is $status_code . All seems to be working. Continue with updating the plugins .. " | |
else | |
echo "Site seems to be broken. Revert back to old version .." | |
wp core update --version="$current_wp_core" --force | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment