This commit is contained in:
apulkin
2026-05-28 11:58:28 +03:00
commit 366ccb7b9a
42 changed files with 8475 additions and 0 deletions
+188
View File
@@ -0,0 +1,188 @@
bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/pve/pbs-microcode.sh)"
# Микрокод процессора — это низкоуровневый программный слой, работающий на процессоре и предоставляющий исправления или обновления для его микропрограммы. Обновления микрокода могут исправлять аппаратные ошибки,
# повышать производительность и улучшать функции безопасности процессора. Этот скрипт адаптирован для среды Proxmox Backup Server и будет работать только на физических системах. При запуске в виртуализированной среде скрипт завершит работу.
# Обратите внимание, что механизмы обновления микропрограммы, такие как Intel Management Engine (ME) или AMD Platform Security Processor (PSP), могут различаться в зависимости от вашего процессора и его реализации. Пожалуйста, обратитесь к
# документации вашего процессора, чтобы проверить, можно ли применить обновления микропрограммы через операционную систему.
#!/usr/bin/env bash
# Copyright (c) 2021-2026 community-scripts ORG
# Author: DonPablo1010 | Co-Author: tteck (tteckster)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
function header_info {
clear
cat <<"EOF"
____ __ ____ __
/ __ \_________ ________ ______________ _____ / |/ (_)_____________ _________ ____/ /__
/ /_/ / ___/ __ \/ ___/ _ \/ ___/ ___/ __ \/ ___/ / /|_/ / / ___/ ___/ __ \/ ___/ __ \/ __ / _ \
/ ____/ / / /_/ / /__/ __(__ |__ ) /_/ / / / / / / / /__/ / / /_/ / /__/ /_/ / /_/ / __/
/_/ /_/ \____/\___/\___/____/____/\____/_/ /_/ /_/_/\___/_/ \____/\___/\____/\__,_/\___/
Proxmox Backup Server Processor Microcode Updater
EOF
}
# Color definitions
RD=$(echo "\033[01;31m")
YW=$(echo "\033[33m")
GN=$(echo "\033[1;92m")
CL=$(echo "\033[m")
BFR="\\r\\033[K"
HOLD="-"
CM="${GN}${CL}"
CROSS="${RD}${CL}"
msg_info() { echo -ne " ${HOLD} ${YW}$1..."; }
# Telemetry
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func) 2>/dev/null || true
declare -f init_tool_telemetry &>/dev/null && init_tool_telemetry "pbs-microcode" "pve"
msg_ok() { echo -e "${BFR} ${CM} ${GN}$1${CL}"; }
msg_error() { echo -e "${BFR} ${CROSS} ${RD}$1${CL}"; }
header_info
# Check if running on bare metal using systemd-detect-virt.
virt=$(systemd-detect-virt)
if [ "$virt" != "none" ]; then
msg_error "This script must be run on bare metal. Detected virtual environment: $virt"
exit 232
fi
# Attempt to obtain the current loaded microcode revision
current_microcode=$(journalctl -k | grep -i 'microcode: Current revision:' | grep -oP 'Current revision: \K0x[0-9a-f]+')
[ -z "$current_microcode" ] && current_microcode="Not found."
intel() {
if ! dpkg -s iucode-tool >/dev/null 2>&1; then
msg_info "Installing iucode-tool (Intel microcode updater)"
apt-get install -y iucode-tool &>/dev/null
msg_ok "Installed iucode-tool"
else
msg_ok "Intel iucode-tool is already installed"
sleep 1
fi
intel_microcode=$(curl -fsSL "https://ftp.debian.org/debian/pool/non-free-firmware/i/intel-microcode/" | grep -o 'href="[^"]*amd64.deb"' | sed 's/href="//;s/"//')
[ -z "$intel_microcode" ] && {
whiptail --backtitle "Proxmox Backup Server Helper Scripts" --title "No Microcode Found" --msgbox "No microcode packages were found.\nTry again later." 10 68
msg_info "Exiting"
sleep 1
msg_ok "Done"
exit
}
MICROCODE_MENU=()
MSG_MAX_LENGTH=0
while read -r TAG ITEM; do
OFFSET=2
((${#ITEM} + OFFSET > MSG_MAX_LENGTH)) && MSG_MAX_LENGTH=$((${#ITEM} + OFFSET))
MICROCODE_MENU+=("$TAG" "$ITEM " "OFF")
done < <(echo "$intel_microcode")
microcode=$(whiptail --backtitle "Proxmox Backup Server Helper Scripts" \
--title "Current Microcode Revision: ${current_microcode}" \
--radiolist "\nSelect a microcode package to install:\n" \
16 $((MSG_MAX_LENGTH + 58)) 6 "${MICROCODE_MENU[@]}" 3>&1 1>&2 2>&3 | tr -d '"')
[ -z "$microcode" ] && {
whiptail --backtitle "Proxmox Backup Server Helper Scripts" --title "No Microcode Selected" --msgbox "No microcode package was selected." 10 68
msg_info "Exiting"
sleep 1
msg_ok "Done"
exit
}
msg_info "Downloading Intel processor microcode package $microcode"
curl -fsSL "http://ftp.debian.org/debian/pool/non-free-firmware/i/intel-microcode/$microcode" -o $(basename "http://ftp.debian.org/debian/pool/non-free-firmware/i/intel-microcode/$microcode")
msg_ok "Downloaded Intel processor microcode package $microcode"
msg_info "Installing $microcode (this might take a while)"
dpkg -i $microcode &>/dev/null
msg_ok "Installed $microcode"
msg_info "Cleaning up"
rm $microcode
msg_ok "Clean up complete"
echo -e "\nA system reboot is required to apply the changes.\n"
}
amd() {
amd_microcode=$(curl -fsSL "https://ftp.debian.org/debian/pool/non-free-firmware/a/amd64-microcode/" | grep -o 'href="[^"]*amd64.deb"' | sed 's/href="//;s/"//')
[ -z "$amd_microcode" ] && {
whiptail --backtitle "Proxmox Backup Server Helper Scripts" --title "No Microcode Found" --msgbox "No microcode packages were found.\nTry again later." 10 68
msg_info "Exiting"
sleep 1
msg_ok "Done"
exit
}
MICROCODE_MENU=()
MSG_MAX_LENGTH=0
while read -r TAG ITEM; do
OFFSET=2
((${#ITEM} + OFFSET > MSG_MAX_LENGTH)) && MSG_MAX_LENGTH=$((${#ITEM} + OFFSET))
MICROCODE_MENU+=("$TAG" "$ITEM " "OFF")
done < <(echo "$amd_microcode")
microcode=$(whiptail --backtitle "Proxmox Backup Server Helper Scripts" \
--title "Current Microcode Revision: ${current_microcode}" \
--radiolist "\nSelect a microcode package to install:\n" \
16 $((MSG_MAX_LENGTH + 58)) 6 "${MICROCODE_MENU[@]}" 3>&1 1>&2 2>&3 | tr -d '"')
[ -z "$microcode" ] && {
whiptail --backtitle "Proxmox Backup Server Helper Scripts" --title "No Microcode Selected" --msgbox "No microcode package was selected." 10 68
msg_info "Exiting"
sleep 1
msg_ok "Done"
exit
}
msg_info "Downloading AMD processor microcode package $microcode"
curl -fsSL "https://ftp.debian.org/debian/pool/non-free-firmware/a/amd64-microcode/$microcode" -o $(basename "https://ftp.debian.org/debian/pool/non-free-firmware/a/amd64-microcode/$microcode")
msg_ok "Downloaded AMD processor microcode package $microcode"
msg_info "Installing $microcode (this might take a while)"
dpkg -i $microcode &>/dev/null
msg_ok "Installed $microcode"
msg_info "Cleaning up"
rm $microcode
msg_ok "Clean up complete"
echo -e "\nA system reboot is required to apply the changes.\n"
}
# Check if this is a Proxmox Backup Server by verifying the presence of the datastore config.
if [ ! -f /etc/proxmox-backup/user.cfg ]; then
header_info
msg_error "Proxmox Backup Server not detected!"
exit
fi
whiptail --backtitle "Proxmox Backup Server Helper Scripts" \
--title "Proxmox Backup Server Processor Microcode" \
--yesno "This script searches for CPU microcode packages and offers the option to install them.\nProceed?" 10 68
msg_info "Checking CPU vendor"
cpu=$(lscpu | grep -oP 'Vendor ID:\s*\K\S+' | head -n 1)
if [ "$cpu" == "GenuineIntel" ]; then
msg_ok "${cpu} detected"
sleep 1
intel
elif [ "$cpu" == "AuthenticAMD" ]; then
msg_ok "${cpu} detected"
sleep 1
amd
else
msg_error "CPU vendor ${cpu} is not supported"
exit
fi
+341
View File
@@ -0,0 +1,341 @@
bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/pve/post-pbs-install.sh)"
#!/usr/bin/env bash
# Copyright (c) 2021-2026 community-scripts ORG
# Author: tteck (tteckster) | MickLesk (CanbiZ) | thost96
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
header_info() {
clear
cat <<"EOF"
____ ____ _____ ____ __ ____ __ ____
/ __ \/ __ ) ___/ / __ \____ _____/ /_ / _/___ _____/ /_____ _/ / /
/ /_/ / __ \__ \ / /_/ / __ \/ ___/ __/ / // __ \/ ___/ __/ __ `/ / /
/ ____/ /_/ /__/ / / ____/ /_/ (__ ) /_ _/ // / / (__ ) /_/ /_/ / / /
/_/ /_____/____/ /_/ \____/____/\__/ /___/_/ /_/____/\__/\__,_/_/_/
EOF
}
RD=$(echo "\033[01;31m")
YW=$(echo "\033[33m")
GN=$(echo "\033[1;92m")
CL=$(echo "\033[m")
BFR="\\r\\033[K"
HOLD="-"
CM="${GN}${CL}"
CROSS="${RD}${CL}"
set -euo pipefail
shopt -s inherit_errexit nullglob
msg_info() { echo -ne " ${HOLD} ${YW}$1..."; }
msg_ok() { echo -e "${BFR} ${CM} ${GN}$1${CL}"; }
msg_error() { echo -e "${BFR} ${CROSS} ${RD}$1${CL}"; }
# Telemetry
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func) 2>/dev/null || true
declare -f init_tool_telemetry &>/dev/null && init_tool_telemetry "post-pbs-install" "pve"
# ---- helpers ----
get_pbs_codename() {
awk -F'=' '/^VERSION_CODENAME=/{print $2}' /etc/os-release
}
repo_state_list() {
local repo="$1"
local file=""
local state="missing"
for f in /etc/apt/sources.list /etc/apt/sources.list.d/*.list; do
[[ -f "$f" ]] || continue
if grep -q "$repo" "$f"; then
file="$f"
if grep -qE "^[^#].*${repo}" "$f"; then
state="active"
elif grep -qE "^#.*${repo}" "$f"; then
state="disabled"
fi
break
fi
done
echo "$state $file"
}
component_exists_in_sources() {
local component="$1"
grep -h -E "^[^#]*Components:[^#]*\b${component}\b" /etc/apt/sources.list.d/*.sources 2>/dev/null | grep -q .
}
require_whiptail() {
if ! command -v whiptail >/dev/null 2>&1; then
msg_error "Missing dependency: whiptail"
echo -e "Install it first (e.g. apt update && apt install -y whiptail), then re-run this script."
exit 127
fi
}
# ---- main ----
main() {
header_info
echo -e "\nThis script will Perform Post Install Routines.\n"
while true; do
read -rp "Start the Proxmox Backup Server Post Install Script (y/n)? " yn
case $yn in
[Yy]*) break ;;
[Nn]*)
clear
exit
;;
*) echo "Please answer yes or no." ;;
esac
done
if command -v pveversion >/dev/null 2>&1; then
echo -e "\n🛑 PVE Detected, Wrong Script!\n"
exit 232
fi
local CODENAME
CODENAME="$(get_pbs_codename)"
case "$CODENAME" in
bookworm)
require_whiptail
start_routines_3
;;
trixie)
require_whiptail
start_routines_4
;;
*)
msg_error "Unsupported Debian codename: $CODENAME"
echo -e "Supported: bookworm (PBS 3.x) and trixie (PBS 4.x)"
exit 105
;;
esac
}
# ---- PBS 3.x (Bookworm) ----
start_routines_3() {
header_info
local VERSION="bookworm"
# --- Debian sources ---
CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PBS SOURCES" --menu \
"Correct Debian sources for Proxmox Backup Server 3.x?" 14 58 2 "yes" " " "no" " " 3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Correcting Debian Sources"
cat <<EOF >/etc/apt/sources.list
deb http://deb.debian.org/debian ${VERSION} main contrib
deb http://deb.debian.org/debian ${VERSION}-updates main contrib
deb http://security.debian.org/debian-security ${VERSION}-security main contrib
EOF
msg_ok "Corrected Debian Sources"
;;
no) msg_error "Selected no to Correcting Debian Sources" ;;
esac
# --- Enterprise repo ---
read -r state file <<<"$(repo_state_list pbs-enterprise)"
case $state in
active)
sed -i "s/^[^#].*pbs-enterprise/# &/" "$file"
msg_ok "Disabled 'pbs-enterprise' repository"
;;
disabled) msg_ok "'pbs-enterprise' already disabled" ;;
missing)
cat >/etc/apt/sources.list.d/pbs-enterprise.list <<EOF
# deb https://enterprise.proxmox.com/debian/pbs ${VERSION} pbs-enterprise
EOF
msg_ok "Added 'pbs-enterprise' repository (disabled)"
;;
esac
# --- No-subscription repo ---
read -r state file <<<"$(repo_state_list pbs-no-subscription)"
if [[ "$state" == "missing" ]]; then
cat >/etc/apt/sources.list.d/pbs-install-repo.list <<EOF
deb http://download.proxmox.com/debian/pbs ${VERSION} pbs-no-subscription
EOF
msg_ok "Enabled 'pbs-no-subscription' repository"
else
msg_ok "'pbs-no-subscription' repository already present"
fi
# --- Test repo (legacy name pbstest) ---
read -r state file <<<"$(repo_state_list pbstest)"
if [[ "$state" == "missing" ]]; then
cat >/etc/apt/sources.list.d/pbstest-for-beta.list <<EOF
# deb http://download.proxmox.com/debian/pbs ${VERSION} pbstest
EOF
msg_ok "Added 'pbstest' repository (disabled)"
else
msg_ok "'pbstest' repository already exists"
fi
post_routines_common
}
# ---- PBS 4.x (Trixie, deb822) ----
start_routines_4() {
header_info
local VERSION="trixie"
# --- Debian sources (deb822) ---
CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PBS SOURCES" --menu \
"Correct Debian sources for Proxmox Backup Server 4.x (deb822)?" 14 58 2 "yes" " " "no" " " 3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Correcting Debian Sources (deb822)"
rm -f /etc/apt/sources.list.d/*.list
if [ -f /etc/apt/sources.list ]; then
sed -i '/proxmox/d;/bookworm/d' /etc/apt/sources.list
fi
cat >/etc/apt/sources.list.d/debian.sources <<EOF
Types: deb
URIs: http://deb.debian.org/debian/
Suites: trixie trixie-updates
Components: main contrib non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
Types: deb
URIs: http://security.debian.org/debian-security/
Suites: trixie-security
Components: main contrib non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
EOF
msg_ok "Corrected Debian Sources"
;;
no) msg_error "Selected no to Correcting Debian Sources" ;;
esac
# --- Enterprise repo ---
if component_exists_in_sources "pbs-enterprise"; then
CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PBS Enterprise Repository" --menu \
"Enterprise repository detected.
You normally need a valid subscription for this.
Disable it (recommended)?" 14 58 2 "yes" " " "no" " " 3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Disabling 'pbs-enterprise' repository"
# Use Enabled: false instead of commenting to avoid malformed entry
if grep -q "^Enabled:" /etc/apt/sources.list.d/pbs-enterprise.sources 2>/dev/null; then
sed -i 's/^Enabled:.*/Enabled: false/' /etc/apt/sources.list.d/pbs-enterprise.sources
else
echo "Enabled: false" >>/etc/apt/sources.list.d/pbs-enterprise.sources
fi
msg_ok "Disabled 'pbs-enterprise' repository"
;;
no)
msg_error "Keeping 'pbs-enterprise' active (subscription required!)"
;;
esac
else
cat >/etc/apt/sources.list.d/pbs-enterprise.sources <<EOF
Types: deb
URIs: https://enterprise.proxmox.com/debian/pbs
Suites: trixie
Components: pbs-enterprise
Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg
Enabled: false
EOF
msg_ok "Added 'pbs-enterprise' repository (disabled)"
fi
# --- No-subscription repo ---
if ! component_exists_in_sources "pbs-no-subscription"; then
cat >/etc/apt/sources.list.d/proxmox.sources <<EOF
Types: deb
URIs: http://download.proxmox.com/debian/pbs
Suites: trixie
Components: pbs-no-subscription
Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg
EOF
msg_ok "Added 'pbs-no-subscription' repository"
else
msg_ok "'pbs-no-subscription' repository already present"
fi
# --- Test repo (pbs-test, renamed) ---
if ! component_exists_in_sources "pbs-test"; then
cat >/etc/apt/sources.list.d/pbs-test.sources <<EOF
Types: deb
URIs: http://download.proxmox.com/debian/pbs
Suites: trixie
Components: pbs-test
Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg
Enabled: false
EOF
msg_ok "Added 'pbs-test' repository (disabled)"
else
msg_ok "'pbs-test' repository already present"
fi
post_routines_common
}
# ---- Shared routines ----
post_routines_common() {
# Subscription nag
CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "SUBSCRIPTION NAG" --menu \
"Disable subscription nag in PBS UI?" 14 58 2 "yes" " " "no" " " 3>&2 2>&1 1>&3)
case $CHOICE in
yes)
whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox \
"Supporting the software's development team is essential.\nPlease consider buying a subscription." 10 58
msg_info "Disabling subscription nag"
echo "DPkg::Post-Invoke { \"if [ -s /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js ] && ! grep -q -F 'NoMoreNagging' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js; then sed -i '/data\\.status/{s/\\!//;s/active/NoMoreNagging/}' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js; fi\" };" >/etc/apt/apt.conf.d/no-nag-script
msg_ok "Disabled subscription nag (clear browser cache!)"
;;
no)
msg_error "Selected no to Disabling subscription nag"
rm -f /etc/apt/apt.conf.d/no-nag-script 2>/dev/null
;;
esac
apt --reinstall install proxmox-widget-toolkit &>/dev/null || msg_error "Widget toolkit reinstall failed"
# Update
CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "UPDATE" --menu \
"Update Proxmox Backup Server now?" 11 58 2 "yes" " " "no" " " 3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Updating Proxmox Backup Server (Patience)"
apt update &>/dev/null || msg_error "apt update failed"
apt -y dist-upgrade &>/dev/null || msg_error "apt dist-upgrade failed"
msg_ok "Updated Proxmox Backup Server"
;;
no) msg_error "Selected no to updating Proxmox Backup Server" ;;
esac
# Reminder
whiptail --backtitle "Proxmox VE Helper Scripts" --title "Post-Install Reminder" --msgbox \
"IMPORTANT:
Please run this script on every PBS node individually if you have multiple nodes.
After completing these steps, it is strongly recommended to REBOOT your node.
After the upgrade or post-install routines, always clear your browser cache or perform a hard reload (Ctrl+Shift+R) before using the PBS Web UI to avoid UI display issues." 20 80
# Reboot
CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "REBOOT" --menu \
"Reboot Proxmox Backup Server now? (recommended)" 11 58 2 "yes" " " "no" " " 3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Rebooting PBS"
sleep 2
msg_ok "Completed Post Install Routines"
reboot
;;
no)
msg_error "Selected no to Reboot (Reboot recommended)"
msg_ok "Completed Post Install Routines"
;;
esac
}
main
+49
View File
@@ -0,0 +1,49 @@
#pve
bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/ct/proxmox-backup-server.sh)"
#!/usr/bin/env bash
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
# Copyright (c) 2021-2026 tteck
# Author: tteck (tteckster)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://www.proxmox.com/en/proxmox-backup-server
APP="Proxmox-Backup-Server"
var_tags="${var_tags:-backup}"
var_cpu="${var_cpu:-2}"
var_ram="${var_ram:-2048}"
var_disk="${var_disk:-10}"
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 [[ ! -e /usr/sbin/proxmox-backup-manager ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
msg_info "Updating $APP LXC"
$STD apt update
$STD apt -y upgrade
msg_ok "Updated $APP LXC"
msg_ok "Updated successfully!"
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}https://${IP}:8007${CL}"
+191
View File
@@ -0,0 +1,191 @@
bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/pve/pbs4-upgrade.sh)"
#!/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
header_info() {
clear
cat <<"EOF"
____ ____ _____ __ __ __ __ __
/ __ \/ __ ) ___// // / / / / /___ ____ __________ _____/ /__
/ /_/ / __ \__ \/ // /_ / / / / __ \/ __ `/ ___/ __ `/ __ / _ \
/ ____/ /_/ /__/ /__ __/ / /_/ / /_/ / /_/ / / / /_/ / /_/ / __/
/_/ /_____/____/ /_/ \____/ .___/\__, /_/ \__,_/\__,_/\___/
/_/ /____/
EOF
}
RD=$(echo "\033[01;31m")
YW=$(echo "\033[33m")
GN=$(echo "\033[1;92m")
CL=$(echo "\033[m")
BFR="\\r\\033[K"
HOLD="-"
CM="${GN}${CL}"
CROSS="${RD}${CL}"
set -euo pipefail
shopt -s inherit_errexit nullglob
msg_info() { echo -ne " ${HOLD} ${YW}$1..."; }
msg_ok() { echo -e "${BFR} ${CM} ${GN}$1${CL}"; }
msg_error() { echo -e "${BFR} ${CROSS} ${RD}$1${CL}"; }
# Telemetry
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func) 2>/dev/null || true
declare -f init_tool_telemetry &>/dev/null && init_tool_telemetry "pbs4-upgrade" "pve"
start_routines() {
header_info
CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PBS 3 BACKUP" --menu \
"\nMake a backup of /etc/proxmox-backup to ensure recovery in worst case?" 14 58 2 \
"yes" " " "no" " " 3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Backing up Proxmox Backup Server 3"
tar czf "pbs3-etc-backup-$(date -I).tar.gz" -C "/etc" "proxmox-backup"
msg_ok "Backed up Proxmox Backup Server 3"
;;
no) msg_error "Selected no to Backup" ;;
esac
# --- Debian 13 Sources ---
CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PBS 4 SOURCES" --menu \
"Switch to Debian 13 (Trixie) sources for PBS 4?" 14 58 2 "yes" " " "no" " " 3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Switching to Debian 13 (Trixie) Sources"
rm -f /etc/apt/sources.list.d/*.list
if [ -f /etc/apt/sources.list ]; then
sed -i '/proxmox/d;/bookworm/d' /etc/apt/sources.list
fi
cat >/etc/apt/sources.list.d/debian.sources <<EOF
Types: deb
URIs: http://deb.debian.org/debian
Suites: trixie
Components: main contrib
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
Types: deb
URIs: http://security.debian.org/debian-security
Suites: trixie-security
Components: main contrib
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
Types: deb
URIs: http://deb.debian.org/debian
Suites: trixie-updates
Components: main contrib
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
EOF
msg_ok "Configured Debian 13 (Trixie) Sources"
;;
no) msg_error "Selected no to Sources update" ;;
esac
# --- Enterprise Repo ---
CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PBS4-ENTERPRISE" --menu \
"Add 'pbs-enterprise' repository (for subscription users)?" 14 58 2 "yes" " " "no" " " \
3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Adding 'pbs-enterprise' repository"
cat >/etc/apt/sources.list.d/pbs-enterprise.sources <<EOF
Types: deb
URIs: https://enterprise.proxmox.com/debian/pbs
Suites: trixie
Components: pbs-enterprise
Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg
EOF
msg_ok "Added 'pbs-enterprise' repository"
;;
no) msg_error "Skipped enterprise repo" ;;
esac
# --- No-Subscription Repo ---
CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PBS4-NO-SUBSCRIPTION" --menu \
"Enable 'pbs-no-subscription' repository?" 14 58 2 "yes" " " "no" " " \
3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Adding 'pbs-no-subscription' repository"
cat >/etc/apt/sources.list.d/proxmox.sources <<EOF
Types: deb
URIs: http://download.proxmox.com/debian/pbs
Suites: trixie
Components: pbs-no-subscription
Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg
EOF
msg_ok "Added 'pbs-no-subscription' repository"
;;
no) msg_error "Skipped no-subscription repo" ;;
esac
# --- Test Repo ---
CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PBS4 TEST" --menu \
"Add 'pbs-test' repository (disabled by default)?" 14 58 2 "yes" " " "no" " " \
3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Adding 'pbs-test' repository (disabled)"
cat >/etc/apt/sources.list.d/pbs-test.sources <<EOF
# Types: deb
# URIs: http://download.proxmox.com/debian/pbs
# Suites: trixie
# Components: pbs-test
# Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg
EOF
msg_ok "Added 'pbs-test' repository"
;;
no) msg_error "Skipped test repo" ;;
esac
# --- Upgrade ---
CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "PBS 4 UPGRADE" --menu \
"\nUpgrade to Proxmox Backup Server 4 now?" 11 58 2 "yes" " " "no" " " \
3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Upgrading to Proxmox Backup Server 4 (Patience)"
apt update
DEBIAN_FRONTEND=noninteractive apt -o Dpkg::Options::="--force-confold" dist-upgrade -y
msg_ok "System upgraded to PBS 4"
;;
no) msg_error "Selected no to upgrade" ;;
esac
# --- Reboot ---
CHOICE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "REBOOT" --menu \
"\nReboot Proxmox Backup Server 4 now? (recommended)" 11 58 2 "yes" " " "no" " " \
3>&2 2>&1 1>&3)
case $CHOICE in
yes)
msg_info "Rebooting PBS 4"
sleep 2
msg_ok "Upgrade Complete"
reboot
;;
no)
msg_error "Selected no to Reboot (Reboot recommended)"
msg_ok "Upgrade Complete"
;;
esac
}
header_info
while true; do
read -rp "Start the Upgrade to Proxmox Backup Server 4 Script (y/n)? " yn
case $yn in
[Yy]*) break ;;
[Nn]*)
clear
exit
;;
*) echo "Please answer yes or no." ;;
esac
done
start_routines