Skip to content

Commit

Permalink
Added Step 4 to clean up after Backdrop Core Upgrade. Tidied up the s…
Browse files Browse the repository at this point in the history
…cripts a little
  • Loading branch information
francis committed Mar 8, 2023
1 parent f7713ce commit ccc8086
Show file tree
Hide file tree
Showing 18 changed files with 74 additions and 37 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Backdrop Upgrade Made Easy

## Prequisites
## Prerequisites

You will need to have Git, Ansible and Bee (https://github.com/backdrop-contrib/bee) installed. Ansible Documentation is [here](https://docs.ansible.com/ansible/latest/index.html)

With Ansible you will need to have your own Ansible Hosts File setup for the Local, Dev and Prod Servers and correct the scripts accordingly. They do not need Sudo, just run as a normal user, but you will need ssh keys setup on the remote and local servers for paswordless login.
With Ansible, you will need to have your own Ansible Hosts File setup for the Local, Dev and Prod Servers and correct the scripts accordingly. They do not need Sudo, just run as a normal user, but you will need ssh keys setup on the remote and local servers for password less login.

## To upgrade I follow this workflow:

Expand All @@ -18,7 +18,7 @@ It is useful to have a standard naming convention, so I use <SiteName>.local, <S
My Local Sites are on a local server and the Dev and Prod on remote servers.

*IMPORTANT!*
I have created Bash Scripts to export and import the site configuration and database. Also to upgrade core and modules. These can be found on github [here](https://github.com/TheMetMan/backdrop-web-install) as well. See that project for more information.
I have created Bash Scripts to export and import the site configuration and database. Also, to upgrade core and modules. These can be found on GitHub [here](https://github.com/TheMetMan/backdrop-web-install) as well. See that project for more information.

## Automation and Streamlining:

Expand All @@ -33,7 +33,8 @@ In more detail:
~/ansible/backdrop_upgrade_made_easy/backdrop_run_step_2.sh
3. Create Git upgrade Branch on Local and Git Pull from Remote. Then ImportConfigSync.
~/ansible/backdrop_upgrade_made_easy/backdrop_run_step_3.sh
4. Test Local Sites are OK.
4. Test Local Sites are OK, then clean up.
~/ansible/backdrop_upgrade_made_easy/backdrop_run_step_4.sh
5. Upgrade Core and any modules then ExportConfigSync and Git Commit Upgrade.
~/ansible/backdrop_upgrade_made_easy/backdrop_run_step_5.sh
6. Test Local Sites are OK.
Expand Down
4 changes: 2 additions & 2 deletions backdrop_run_step_1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
#
# Reset BASH time counter
SECONDS=0
cd "${HOME}/ansible"
cd "${HOME}/ansible" || exit
echo "Running Playbook for Remote Prod"
ansible-playbook ~/ansible/backdrop_upgrade_made_easy/playbooks/backdrop_step_1_remote_prod.yaml
echo "Running Playbook for Remote Dev"
ansible-playbook ~/ansible/backdrop_upgrade_made_easy/playbooks/backdrop_step_1_remote_dev.yaml
echo "Running Playbook for Local"
ansible-playbook ~/ansible/backdrop_upgrade_made_easy/playbooks/backdrop_step_1_local.yaml
echo "Finished"
ELAPSED="Elapsed: $(($SECONDS / 3600))hrs $((($SECONDS / 60) % 60))min $(($SECONDS % 60))sec"
ELAPSED="Elapsed: (($SECONDS / 3600))hrs ((($SECONDS / 60) % 60))min (($SECONDS % 60))sec"
echo "${ELAPSED}"

2 changes: 1 addition & 1 deletion backdrop_run_step_2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
#
SECONDS=0
ansible-playbook ~/ansible/backdrop_upgrade_made_easy/playbooks/backdrop_step_2.yaml -v
ELAPSED="Elapsed: $(($SECONDS / 3600))hrs $((($SECONDS / 60) % 60))min $(($SECONDS % 60))sec"
ELAPSED="Elapsed: (($SECONDS / 3600))hrs ((($SECONDS / 60) % 60))min (($SECONDS % 60))sec"
echo "${ELAPSED}"

2 changes: 1 addition & 1 deletion backdrop_run_step_3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
#
SECONDS=0
ansible-playbook ~/ansible/backdrop_upgrade_made_easy/playbooks/backdrop_step_3.yaml -v
ELAPSED="Elapsed: $(($SECONDS / 3600))hrs $((($SECONDS / 60) % 60))min $(($SECONDS % 60))sec"
ELAPSED="Elapsed: (($SECONDS / 3600))hrs ((($SECONDS / 60) % 60))min (($SECONDS % 60))sec"
echo "${ELAPSED}"

9 changes: 9 additions & 0 deletions backdrop_run_step_4.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
#
# Script to run Step 4 in Backdrop Upgrade
#
SECONDS=0
ansible-playbook ~/ansible/backdrop_upgrade_made_easy/playbooks/backdrop_step_4.yaml -v
ELAPSED="Elapsed: (($SECONDS / 3600))hrs ((($SECONDS / 60) % 60))min (($SECONDS % 60))sec"
echo "${ELAPSED}"

2 changes: 1 addition & 1 deletion backdrop_run_step_5.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
#
SECONDS=0
ansible-playbook ~/ansible/backdrop_upgrade_made_easy/playbooks/backdrop_step_5.yaml -v
ELAPSED="Elapsed: $(($SECONDS / 3600))hrs $((($SECONDS / 60) % 60))min $(($SECONDS % 60))sec"
ELAPSED="Elapsed: (($SECONDS / 3600))hrs ((($SECONDS / 60) % 60))min (($SECONDS % 60))sec"
echo "${ELAPSED}"

2 changes: 1 addition & 1 deletion backdrop_run_step_7.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
#
SECONDS=0
ansible-playbook ~/ansible/backdrop_upgrade_made_easy/playbooks/backdrop_step_7.yaml -v
ELAPSED="Elapsed: $(($SECONDS / 3600))hrs $((($SECONDS / 60) % 60))min $(($SECONDS % 60))sec"
ELAPSED="Elapsed: (($SECONDS / 3600))hrs ((($SECONDS / 60) % 60))min (($SECONDS % 60))sec"
echo "${ELAPSED}"

2 changes: 1 addition & 1 deletion backdrop_run_step_8_01.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
#
SECONDS=0
ansible-playbook ~/ansible/backdrop_upgrade_made_easy/playbooks/backdrop_step_8_dev.yaml -v
ELAPSED="Elapsed: $(($SECONDS / 3600))hrs $((($SECONDS / 60) % 60))min $(($SECONDS % 60))sec"
ELAPSED="Elapsed: (($SECONDS / 3600))hrs ((($SECONDS / 60) % 60))min (($SECONDS % 60))sec"
echo "${ELAPSED}"

2 changes: 1 addition & 1 deletion backdrop_run_step_8_02.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
#
SECONDS=0
ansible-playbook ~/ansible/backdrop_upgrade_made_easy/playbooks/backdrop_step_8_prod.yaml -v
ELAPSED="Elapsed: $(($SECONDS / 3600))hrs $((($SECONDS / 60) % 60))min $(($SECONDS % 60))sec"
ELAPSED="Elapsed: (($SECONDS / 3600))hrs ((($SECONDS / 60) % 60))min (($SECONDS % 60))sec"
echo "${ELAPSED}"

2 changes: 1 addition & 1 deletion backdrop_run_step_9.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
#
SECONDS=0
ansible-playbook ~/ansible/backdrop_upgrade_made_easy/playbooks/backdrop_step_9.yaml -v
ELAPSED="Elapsed: $(($SECONDS / 3600))hrs $((($SECONDS / 60) % 60))min $(($SECONDS % 60))sec"
ELAPSED="Elapsed: (($SECONDS / 3600))hrs ((($SECONDS / 60) % 60))min (($SECONDS % 60))sec"
echo "${ELAPSED}"

2 changes: 1 addition & 1 deletion backdrop_step_1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PATH=$HOME/.local/bin:$HOME/bin:$PATH
pattern="$1"
result=0
for _dir in "${HOME}"/apps/*"${pattern}"; do
cd "${_dir}"
cd "${_dir}" || exit
branch=$(git branch | grep up)
if [[ $branch ]]; then
echo "${_dir}"
Expand Down
2 changes: 1 addition & 1 deletion backdrop_step_2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pattern="$1"
# pattern="lab_dev"
for _dir in "${HOME}"/apps/*"${pattern}"*; do
echo "${_dir}"
cd "${_dir}"
cd "${_dir}" || exit
git status
./exportConfigSync
git add -A
Expand Down
14 changes: 7 additions & 7 deletions backdrop_step_3.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#!/bin/bash
#
# Script as Step 3 in Upgrading Backdrop
#
#
#
PATH=$HOME/.local/bin:$HOME/bin:$PATH
pattern="$1"
result=0
#for _dir in "${HOME}"/FG-Docs/public_html/*"${pattern}"; do
for _dir in "${HOME}"/apps/*"${pattern}"; do
echo "${_dir}"
cd "${_dir}"
git status
git checkout -b upgrade
git pull origin master
./importConfigSync
echo "${_dir}"
cd "${_dir}" || exit
git status
git checkout -b upgrade
git pull origin master
./importConfigSync
done
exit ${result}
15 changes: 15 additions & 0 deletions backdrop_step_4.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
#
# Script as Step 4 in Upgrading Backdrop to clean up temporary folders
#
#
PATH=$HOME/.local/bin:$HOME/bin:$PATH
pattern="$1"
result=0
for _dir in "${HOME}"/FG-Docs/public_html/*"${pattern}/web"; do
#for _dir in "${HOME}"/apps/*"${pattern}"; do
echo "${_dir}"
cd "${_dir}" || exit
rm -fr "core_*"
done
exit ${result}
31 changes: 18 additions & 13 deletions backdrop_step_5.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,40 @@
PATH=$HOME/.local/bin:$HOME/bin:$PATH
pattern="$1"
result=0
TEMP_FOLDER="/dev/shm/backdrop"

for _dir in "${HOME}"/apps/*"${pattern}"; do
echo "${_dir}"
cd "${_dir}"
cd "${_dir}" || exit
FOLDER=$(basename "$PWD")
# echo "${FOLDER}"
./backupEssentials "${FOLDER}"
cd "${_dir}/web"
echo "Upgrade Core"
if [ -d "${TEMP_FOLDER}" ]; then
rm -fr "${TEMP_FOLDER}"
cd "${_dir}/web" || exit
# ------------------------------------------------------------
echo "Checking Upgrade Core is REALLY necessary"
mkdir "/dev/shm/core_tmp"
bee dl-core "/dev/shm/core_tmp"
read -ra latest_array <<< $(cat "/dev/shm/core_tmp/core/profiles/standard/standard.info" | grep 'version = 1')
echo "${latest_array[2]}"
if [ "${latest_array[2]}" != "${version}" ]; then
echo "Upgrading Core"
mv core "core_${version}"
mv /dev/shm/core_tmp/core .
else
echo "Core Upgrade Not Necessary"
fi
mkdir "${TEMP_FOLDER}"
bee dl-core /dev/shm/backdrop
# rm -fr core
mv core "core_${version}"
rsync -arz "${TEMP_FOLDER}/core" .
rm -fr /dev/shm/core_tmp
echo ""
echo "Upgrade Modules & Themes"
bee update -y
echo ""
bee updb -y
bee cc all
cd "${_dir}"
cd "${_dir}" || exit
./exportConfigSync
git add -A
git commit -am "Upgraded Backdrop Core & Modules as required"
done
echo "Now check that all is well with the site before merging and pushing to dev & prod"
echo "Now check that all is well with the site before deleting the core_${version} folder"
echo "THen merging and push to dev & prod"
exit ${result}

2 changes: 1 addition & 1 deletion backdrop_step_7.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pattern="$1"
result=0
for _dir in "${HOME}"/apps/*"${pattern}"; do
echo "${_dir}"
cd "${_dir}"
cd "${_dir}" || exit
echo "Merging to Master"
git checkout master
git merge upgrade
Expand Down
2 changes: 1 addition & 1 deletion backdrop_step_9.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ for pattern in "${patterns[@]}"; do
for _dir in "${HOME}"/apps/*"${pattern}"; do
# echo "Pattern = ${pattern}"
echo "Directory = ${_dir}"
cd "${_dir}"
cd "${_dir}" || exit
git status
git checkout master
git merge upgrade
Expand Down
7 changes: 7 additions & 0 deletions playbooks/backdrop_step_4.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# PlayBook to execute Stage 4 in the Backdrop Upgrade
#
- hosts: backdrop_servers_local
gather_facts: true
tasks:
- name: Script to Cleanup temporary folders after Core Upgrade
ansible.builtin.script: ~/ansible/backdrop_upgrade_made_easy/backdrop_step_4.sh local

0 comments on commit ccc8086

Please sign in to comment.