sportrum-deploy/upgrade-cmds.sh
Claude 54bfeb73e7
Import existing manual deploy scripts as a starting point
These are the scripts currently run by hand on the old EC2 server to do a
full upgrade (safe storeall handshake, backups, explode WAR, run the
manager schema-migration tool, restart Tomcat). Committed as-is for now to
review and refactor from, except tomcat_ctl.sh, which is already rewritten
to control Tomcat via the new Docker container's supervisord (through the
"service" shim) instead of the old host's /etc/init.d/tomcat8, since that
service doesn't exist there. Kept as a drop-in replacement: the "status"
output still contains both literal substrings upgrade.sh and restart.sh
each grep for, so neither caller needed to change yet.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-29 17:04:18 +00:00

33 lines
1.2 KiB
Bash

backupdir="/home/sportrum/backup"
timestamp=$(date +'%Y%m%d-%H%M%S')
sqlbackup="sportrum-upgrade-backup-${timestamp}.sqldump"
webappbackup="sportrum-upgrade-backup-${timestamp}.war"
logsbackup="sportrum-log-backup-${timestamp}"
if [ "$backup_sql" == "true" ]; then
echo "Backup database to ${sqlbackup}..."; sleep 2
pg_dump sportrum > ${backupdir}/sql/${sqlbackup}
else
echo "Backup of database skipped!"
fi
if [ "$backup_war" == "true" ]; then
echo "Backup webapp to ${webappbackup}..."; sleep 2
cd /home/sportrum/webapp
zip -q -r sportrum sportrum
mv sportrum.zip ${backupdir}/webapp/${webappbackup}
else
echo "Backup webapp skipped!"
fi
cd /home/sportrum/webapp
echo "Keep logs in ${backupdir}/logs/${logbackup}..."; sleep 1
mkdir -p ${backupdir}/logs/${logsbackup}
cp sportrum/logs/* ${backupdir}/logs/${logsbackup}
echo "Remove webapp at $(pwd) and unzip new war..."; sleep 2
rm -rf sportrum/* ; unzip -q sportrum.war -d sportrum
chmod -R o+w sportrum/WEB-INF/storage
chmod -R o+w sportrum/logs
cd /home/sportrum/
echo "Upgrade DB using manager at $(pwd)/manager..."; sleep 2
rm -rf manager ; unzip -q manager.zip ; cd manager
bash -x manager-exec.sh upgrade