Skip to content

Instantly share code, notes, and snippets.

@kcristiano
Last active June 15, 2024 14:49
Show Gist options
  • Save kcristiano/fafcc668df92dff612b265e398b1d0aa to your computer and use it in GitHub Desktop.
Save kcristiano/fafcc668df92dff612b265e398b1d0aa to your computer and use it in GitHub Desktop.
Civi Update
#!/bin/bash
# The script was built for debian - paths may vary
PHPCLI="/usr/local/bin/php"
WPCLI="/usr/local/bin/wp-cli.phar"
WP="/usr/local/bin/wp"
CV="/usr/local/bin/cv"
DATE=$(date +%Y%m%d-%I%M%S)
echo "Hello, "$USER". This script will update CiviCRM."
echo "This script requires minimum version of WordPress 5.4. CiviCRM 5.35 amd PHP 7.3."
read -p "Press [Enter] key to start the backups and updates."
echo -n "Enter the version you need (eg 5.45.3) and press [ENTER]: "
read VER
echo -n "Enter the web root of the site you want to update relative to your home directory (public_html, htdocs, httpfiles etc) and press [ENTER]: "
read SITE
echo -n "Give the backup a name. [ENTER]:"
read NAME
cd $HOME
mkdir cvbkups
tar -czf $HOME/cvbkups/$USER-$NAME-$DATE-civicrm.tgz $HOME/$SITE/wp-content/plugins/civicrm/
cd $HOME/$SITE
# TODO Get DB Names from wp-cli so we can use mysqldump
#mysqldump --defaults-extra-file=$HOME/.my.cnf $wpdb > $HOME/cvbkups/wpdb-$NAME-$DATE.sql
#mysqldump --defaults-extra-file=$HOME/.my.cnf $cvdb > $HOME/cvbkups/cividb-$NAME-$DATE.sql
$WP db export $HOME/cvbkups/wpdb-$NAME-$DATE.sql
$WP cv sql-dump > $HOME/cvbkups/cividb-$NAME-$DATE.sql
ls -lt $HOME/cvbkups
read -p "Press Enter to continue"
cd $HOME/$SITE/wp-content/plugins/civicrm/
git remote set-url origin https://github.com/tadpolecc/civicrm.git
git fetch
git status
#read -p "Press Enter to continue"
git fetch
git checkout $VER
cd $HOME/$SITE
#$WP --path=$HOME/$SITE civicrm cache-clear
$WP --path=$HOME/$SITE civicrm upgrade-db
$WP --path=$HOME/$SITE civicrm api Extension.upgrade
pushd $HOME/$SITE
#$CV --cwd=$HOME/$SITE flush
#$CV --cwd=$HOME/$SITE upgrade:db -vvv
#$CV --cwd=$HOME/$SITE ext:upgrade-db -vvv
popd
echo "now go to yoursite and check it!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment