refactor(ct): migrate manual update backups to create_backup (batch 1)

Replace ad-hoc mv/cp .bak patterns with create_backup/restore_backup across
58 update scripts so failed updates can roll back via the shared ERR trap.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
MickLesk
2026-06-19 23:35:15 +02:00
parent 578089b69e
commit a1f4bc3240
58 changed files with 124 additions and 520 deletions
+5 -10
View File
@@ -34,20 +34,15 @@ function update_script() {
systemctl stop netbox netbox-rq
msg_ok "Stopped Services"
msg_info "Backing up NetBox configurations"
mv /opt/netbox/ /opt/netbox-backup
msg_ok "Backed up NetBox configurations"
create_backup /opt/netbox/netbox/netbox/configuration.py \
/opt/netbox/netbox/media /opt/netbox/netbox/scripts /opt/netbox/netbox/reports \
/opt/netbox/gunicorn.py /opt/netbox/local_requirements.txt \
/opt/netbox/netbox/netbox/ldap_config.py
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "netbox" "netbox-community/netbox" "tarball"
cp -r /opt/netbox-backup/netbox/netbox/configuration.py /opt/netbox/netbox/netbox/
cp -r /opt/netbox-backup/netbox/{media,scripts,reports}/ /opt/netbox/netbox/
cp -r /opt/netbox-backup/gunicorn.py /opt/netbox/
[[ -f /opt/netbox-backup/local_requirements.txt ]] && cp -r /opt/netbox-backup/local_requirements.txt /opt/netbox/
[[ -f /opt/netbox-backup/netbox/netbox/ldap_config.py ]] && cp -r /opt/netbox-backup/netbox/netbox/ldap_config.py /opt/netbox/netbox/netbox/
restore_backup
$STD /opt/netbox/upgrade.sh
rm -r /opt/netbox-backup
msg_info "Starting Services"
systemctl start netbox netbox-rq