Compare commits

...

5 Commits

Author SHA1 Message Date
Sam Heinz b1eec90772 add helper function for get_arch_value 2026-06-12 20:02:52 +10:00
community-scripts-pr-app[bot] 9b5aab46bd Update CHANGELOG.md (#15069)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-06-12 08:59:41 +00:00
push-app-to-main[bot] f321651d6b Twenty (#15047)
* Add twenty (ct)

* Apply suggestion from @tremor021

* Refactor backup and restore process in twenty.sh

Refactored backup and restore logic to use functions.

* Clean up blank lines in twenty.sh

Removed unnecessary blank lines in the script.

---------

Co-authored-by: push-app-to-main[bot] <203845782+push-app-to-main[bot]@users.noreply.github.com>
Co-authored-by: Slaviša Arežina <58952836+tremor021@users.noreply.github.com>
Co-authored-by: Michel Roegl-Brunner <73236783+michelroegl-brunner@users.noreply.github.com>
Co-authored-by: CanbiZ (MickLesk) <47820557+MickLesk@users.noreply.github.com>
2026-06-12 10:59:14 +02:00
community-scripts-pr-app[bot] bcd9678548 Update CHANGELOG.md (#15068)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-06-12 08:23:57 +00:00
Michel Roegl-Brunner a38da170da Implement backup and restore functions (#15067)
Added create_backup and restore_backup functions for standardized data backup and restoration.
2026-06-12 10:23:28 +02:00
7 changed files with 313 additions and 1 deletions
+8 -1
View File
@@ -484,7 +484,14 @@ Exercise vigilance regarding copycat or coat-tailing sites that seek to exploit
### 🆕 New Scripts
- Alpine-Cinny ([#15044](https://github.com/community-scripts/ProxmoxVE/pull/15044))
- Twenty ([#15047](https://github.com/community-scripts/ProxmoxVE/pull/15047))
- Alpine-Cinny ([#15044](https://github.com/community-scripts/ProxmoxVE/pull/15044))
### 💾 Core
- #### ✨ New Features
- [core] Implement backup and restore functions [@michelroegl-brunner](https://github.com/michelroegl-brunner) ([#15067](https://github.com/community-scripts/ProxmoxVE/pull/15067))
## 2026-06-11
+6
View File
@@ -0,0 +1,6 @@
______ __
/_ __/ _____ ____ / /___ __
/ / | | /| / / _ \/ __ \/ __/ / / /
/ / | |/ |/ / __/ / / / /_/ /_/ /
/_/ |__/|__/\___/_/ /_/\__/\__, /
/____/
+84
View File
@@ -0,0 +1,84 @@
#!/usr/bin/env bash
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
# Copyright (c) 2021-2026 community-scripts ORG
# Author: MickLesk (CanbiZ)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/twentyhq/twenty
APP="Twenty"
var_tags="${var_tags:-crm;business;contacts}"
var_cpu="${var_cpu:-4}"
var_ram="${var_ram:-10240}"
var_disk="${var_disk:-20}"
var_os="${var_os:-debian}"
var_version="${var_version:-13}"
var_arm64="${var_arm64:-no}"
var_unprivileged="${var_unprivileged:-1}"
header_info "$APP"
variables
color
catch_errors
function update_script() {
header_info
check_container_storage
check_container_resources
if [[ ! -d /opt/twenty ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
if check_for_gh_release "twenty" "twentyhq/twenty"; then
msg_info "Stopping Services"
systemctl stop twenty-worker twenty-server
msg_ok "Stopped Services"
create_backup /opt/twenty/.env \
/opt/twenty/packages/twenty-server/.local-storage
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "twenty" "twentyhq/twenty" "tarball"
msg_info "Restoring Configuration"
cp /opt/twenty.env.bak /opt/twenty/.env
msg_ok "Restored Configuration"
msg_info "Building Application"
cd /opt/twenty
export COREPACK_ENABLE_DOWNLOAD_PROMPT=0
$STD corepack enable
$STD corepack prepare yarn@4.9.2 --activate
export NODE_OPTIONS="--max-old-space-size=3072"
$STD yarn install --immutable || $STD yarn install
$STD npx nx run twenty-server:build
$STD npx nx build twenty-front
cp -r /opt/twenty/packages/twenty-front/build /opt/twenty/packages/twenty-server/dist/front
unset NODE_OPTIONS
msg_ok "Built Application"
msg_info "Running Database Migrations"
cd /opt/twenty/packages/twenty-server
set -a && source /opt/twenty/.env && set +a
$STD npx ts-node ./scripts/setup-db.ts
$STD npx -y typeorm migration:run -d dist/database/typeorm/core/core.datasource
msg_ok "Ran Database Migrations"
restore_backup
msg_info "Starting Services"
systemctl start twenty-server twenty-worker
msg_ok "Started Services"
msg_ok "Updated successfully!"
fi
exit
}
start
build_container
description
msg_ok "Completed Successfully!\n"
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}"
+106
View File
@@ -0,0 +1,106 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2026 community-scripts ORG
# Author: MickLesk (CanbiZ)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/twentyhq/twenty
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing Dependencies"
$STD apt install -y \
build-essential \
redis-server
msg_ok "Installed Dependencies"
PG_VERSION="17" PG_MODULES="pgvector" setup_postgresql
PG_DB_NAME="twenty_db" PG_DB_USER="twenty" PG_DB_SCHEMA_PERMS="true" PG_DB_EXTENSIONS="vector" setup_postgresql_db
NODE_VERSION="24" setup_nodejs
fetch_and_deploy_gh_release "twenty" "twentyhq/twenty" "tarball"
msg_info "Building Application"
cd /opt/twenty
export COREPACK_ENABLE_DOWNLOAD_PROMPT=0
$STD corepack enable
$STD corepack prepare yarn@4.9.2 --activate
yarn install --immutable >/dev/null 2>&1 || $STD yarn install
export NODE_OPTIONS="--max-old-space-size=4096"
$STD npx nx run twenty-server:build
$STD npx nx build twenty-front
cp -r /opt/twenty/packages/twenty-front/build /opt/twenty/packages/twenty-server/dist/front
unset NODE_OPTIONS
msg_ok "Built Application"
msg_info "Configuring Application"
APP_SECRET=$(openssl rand -base64 32)
mkdir -p /opt/twenty/packages/twenty-server/.local-storage
cat <<EOF >/opt/twenty/.env
NODE_PORT=3000
PG_DATABASE_URL=postgresql://${PG_DB_USER}:${PG_DB_PASS}@localhost:5432/${PG_DB_NAME}
REDIS_URL=redis://localhost:6379
SERVER_URL=http://${LOCAL_IP}:3000
APP_SECRET=${APP_SECRET}
STORAGE_TYPE=local
NODE_ENV=production
EOF
msg_ok "Configured Application"
msg_info "Running Database Migrations"
cd /opt/twenty/packages/twenty-server
set -a && source /opt/twenty/.env && set +a
$STD yarn database:init:prod
msg_ok "Ran Database Migrations"
msg_info "Creating Services"
cat <<EOF >/etc/systemd/system/twenty-server.service
[Unit]
Description=Twenty CRM Server
After=network.target postgresql.service redis-server.service
Requires=postgresql.service redis-server.service
[Service]
Type=simple
User=root
WorkingDirectory=/opt/twenty/packages/twenty-server
EnvironmentFile=/opt/twenty/.env
ExecStart=/usr/bin/node dist/main
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
cat <<EOF >/etc/systemd/system/twenty-worker.service
[Unit]
Description=Twenty CRM Worker
After=network.target postgresql.service redis-server.service twenty-server.service
Requires=postgresql.service redis-server.service
[Service]
Type=simple
User=root
WorkingDirectory=/opt/twenty/packages/twenty-server
EnvironmentFile=/opt/twenty/.env
Environment=DISABLE_DB_MIGRATIONS=true
Environment=DISABLE_CRON_JOBS_REGISTRATION=true
ExecStart=/usr/bin/node dist/queue-worker/queue-worker
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now redis-server twenty-server twenty-worker
msg_ok "Created Services"
motd_ssh
customize
cleanup_lxc
+1
View File
@@ -3838,6 +3838,7 @@ build_container() {
export ENABLE_TUN="$ENABLE_TUN"
export PCT_OSTYPE="$var_os"
export PCT_OSVERSION="$var_version"
export PCT_ARCH="$(dpkg --print-architecture 2>/dev/null || uname -m)"
export PCT_DISK_SIZE="$DISK_SIZE"
export IPV6_METHOD="$IPV6_METHOD"
export ENABLE_GPU="$ENABLE_GPU"
+20
View File
@@ -360,6 +360,26 @@ arch_check() {
fi
}
# ------------------------------------------------------------------------------
# get_arch_value()
#
# - Selects an architecture-specific value while preserving amd64 defaults
# - Usage: get_arch_value "amd64-value" "arm64-value"
# - Defaults: amd64="amd64", arm64="arm64"
# ------------------------------------------------------------------------------
get_arch_value() {
local amd64_val="${1:-amd64}"
local arm64_val="${2:-arm64}"
case "$PCT_ARCH" in
amd64) echo "$amd64_val" ;;
arm64) echo "$arm64_val" ;;
*)
msg_error "Unsupported architecture: $PCT_ARCH"
return 106
;;
esac
}
# ------------------------------------------------------------------------------
# ssh_check()
#
+88
View File
@@ -1123,6 +1123,94 @@ create_temp_dir() {
echo "$tmp_dir"
}
# ------------------------------------------------------------------------------
# create_backup <path> [<path> ...] / restore_backup
#
# Standardized data backup helpers for update_script(). They replace the
# hand-rolled "cp/mv to a sibling dir, update, copy back, rm" dance that is
# duplicated across the ct/*.sh update functions.
#
# create_backup <path> [<path> ...]
# - Copies each given file/directory into a persistent store at
# /opt/<NSAPP>.backup, mirroring its absolute path inside the store, and
# records it in a manifest so restore_backup needs no arguments.
# - Idempotent: if a store from a previous (failed) run already exists, it is
# left untouched and no new backup is taken. This keeps the last-known-good
# data instead of overwriting it with now-partially-updated data on retry.
# - Missing source paths are skipped with a warning (not fatal).
# - Aborts the update on copy failure: if any file/dir cannot be backed up,
# the half-written store is removed and the script exits, so the update
# never runs against unprotected data (and a retry re-attempts a clean
# backup rather than skipping it).
#
# restore_backup
# - Copies every path recorded in the manifest back to its origin (replacing
# whatever the update left there), then deletes the store.
# - No-op (with a warning) if no store exists.
#
# Override the store location with BACKUP_DIR if the default does not fit.
# ------------------------------------------------------------------------------
create_backup() {
local store manifest path dest
store="${BACKUP_DIR:-/opt/${NSAPP:-app}.backup}"
manifest="${store}/.manifest"
[[ $# -eq 0 ]] && {
msg_warn "create_backup called without any paths"
return 0
}
if [[ -f "$manifest" ]]; then
msg_ok "Existing backup found at ${store}, skipping backup"
return 0
fi
msg_info "Backing up data"
if ! mkdir -p "$store" || ! : >"$manifest"; then
msg_error "Backup failed: could not create store at ${store} - aborting update"
rm -rf "$store"
exit 1
fi
for path in "$@"; do
path="${path%/}"
if [[ ! -e "$path" ]]; then
msg_warn "Skipping backup of '${path}' (not found)"
continue
fi
dest="${store}/files${path}"
if ! mkdir -p "$(dirname "$dest")" || ! cp -a "$path" "$dest"; then
msg_error "Backup of '${path}' failed - aborting update"
rm -rf "$store"
exit 1
fi
echo "$path" >>"$manifest"
done
msg_ok "Backed up data to ${store}"
}
restore_backup() {
local store manifest path src
store="${BACKUP_DIR:-/opt/${NSAPP:-app}.backup}"
manifest="${store}/.manifest"
if [[ ! -f "$manifest" ]]; then
msg_warn "No backup found to restore"
return 0
fi
msg_info "Restoring data"
while IFS= read -r path; do
[[ -z "$path" ]] && continue
src="${store}/files${path}"
[[ -e "$src" ]] || continue
mkdir -p "$(dirname "$path")"
rm -rf "$path"
cp -a "$src" "$path"
done <"$manifest"
rm -rf "$store"
msg_ok "Restored data"
}
# ------------------------------------------------------------------------------
# Check if package is installed (supports both Debian and Alpine)
# ------------------------------------------------------------------------------