Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Automated] Merge 5.x into master #203

Merged
merged 2 commits into from
Aug 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions templates/docker-monolithic/backup.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
#!/bin/bash

set -eu -o pipefail

usage="Options:
-h,--help Display this help and exit.

--online Do not restart the services.
"

# Options
online=false

while [[ "$#" -gt 0 ]]; do
case $1 in
-h|--help) echo "$usage" ; exit 0 ;;
--online) online=true ;;
*)
echo "Unknown parameter passed: $1"
exit 1
;;
esac
# shellcheck disable=SC2317
shift
done

BACKUP_DIR="backup"
TIMESTAMP=$(date +%Y-%m-%d-%H-%M-%S)
TEMP_BACKUP_DIR="/tmp/tmp-backups/${TIMESTAMP}"
@@ -12,8 +33,10 @@ APP_BACKUP_NAME="app-${TIMESTAMP}.tar.gz"
GTE_v420="$(docker exec supportpal php -r "\$release = require '/var/www/supportpal/config/release.php'; echo (int) version_compare(\$release['version'], '4.2.0', '>=');")"
if [[ "$GTE_v420" = "0" ]]; then COMMAND_PATH="/var/www/supportpal"; else COMMAND_PATH="/var/www/supportpal/app-manager"; fi

echo "Stopping services..."
docker exec supportpal bash -c "sudo find -L /etc/service -maxdepth 1 -mindepth 1 -type d ! -name 'redis' ! -name '00redis' ! -name 'mysql' ! -name '00mysql' -printf '%f\n' -exec sv stop {} \;"
if ! $online; then
echo "Stopping services..."
docker exec supportpal bash -c "sudo find -L /etc/service -maxdepth 1 -mindepth 1 -type d ! -name 'redis' ! -name '00redis' ! -name 'mysql' ! -name '00mysql' -printf '%f\n' -exec sv stop {} \;"
fi

echo 'Backing up filesystem...'
docker exec supportpal bash -c "mkdir -p ${TEMP_BACKUP_DIR}/filesystem-${TIMESTAMP}/config/production" # create the farthest directory
@@ -42,7 +65,9 @@ mkdir -p "${BACKUP_DIR}/"
docker cp "supportpal:${TEMP_BACKUP_DIR}/${APP_BACKUP_NAME}" "${BACKUP_DIR}/"
docker exec -u root supportpal bash -c "rm -rf ${TEMP_BACKUP_DIR}/"

echo "Restarting services..."
docker restart supportpal
if ! $online; then
echo "Restarting services..."
docker restart supportpal
fi

echo "Backup created successfully at ${PWD}/${BACKUP_DIR}/${APP_BACKUP_NAME}"