From 94ab107f3f607e51862589e2c9c1d9597994929b Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner <73236783+michelroegl-brunner@users.noreply.github.com> Date: Fri, 12 Jun 2026 10:27:23 +0200 Subject: [PATCH] Refactor backup and restore process in twenty.sh Refactored backup and restore logic to use functions. --- ct/twenty.sh | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/ct/twenty.sh b/ct/twenty.sh index 9c42405b8..dd00bae61 100644 --- a/ct/twenty.sh +++ b/ct/twenty.sh @@ -36,10 +36,10 @@ function update_script() { systemctl stop twenty-worker twenty-server msg_ok "Stopped Services" - msg_info "Backing up Data" - cp /opt/twenty/.env /opt/twenty.env.bak - cp -r /opt/twenty/packages/twenty-server/.local-storage /opt/twenty_storage_backup 2>/dev/null || true - msg_ok "Backed up Data" + + create_backup /opt/twenty/.env \ + /opt/twenty/packages/twenty-server/.local-storage + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "twenty" "twentyhq/twenty" "tarball" @@ -67,10 +67,7 @@ function update_script() { $STD npx -y typeorm migration:run -d dist/database/typeorm/core/core.datasource msg_ok "Ran Database Migrations" - msg_info "Restoring Storage" - cp -r /opt/twenty_storage_backup/. /opt/twenty/packages/twenty-server/.local-storage/ 2>/dev/null || true - rm -rf /opt/twenty_storage_backup /opt/twenty.env.bak - msg_ok "Restored Storage" + restore_backup msg_info "Starting Services" systemctl start twenty-server twenty-worker