<SergioBrighenti />
Back to Blog

Migrating a HestiaCP Server to Debian 13

November 25, 2026 Sergio Brighenti

I wrote these notes so I could repeat a server migration without having to remember which steps belonged on which machine. The starting point is a fresh Debian 13 server and an existing HestiaCP server with accounts to move. The old server stays available until the sites, databases and mail work on the new one.

My setup uses Nginx in front of Apache, PHP-FPM with multiple PHP versions, and MariaDB 12.3. For applications that run in containers, I use rootless Podman and publish their web interfaces through Hestia. Skip the Podman and Arcane chapters if you only host conventional sites. The account transfer uses Hestia's traditional .tar backups.

Before you start

  • Provision a clean 64-bit Debian 13 (Trixie) image. Leave Apache, Nginx, PHP and MariaDB to the Hestia installer. Hestia installation requirements
  • Make sure you can reach the provider's recovery console and edit the domains' DNS records, including reverse DNS (PTR) at the IP provider.
  • Keep an independent backup and retain the source server until you have verified the migration. Work on the new server unless a step explicitly names the old one or your own computer.
  • Replace the example accounts, domains and documentation IP addresses with your own values. Work through one block at a time so you can check the result before continuing.

Contents

  1. First login
  2. Prepare Debian
  3. Administrative account and SSH
  4. Install and configure HestiaCP
  5. Rootless Podman and Arcane
  6. Set up a reverse proxy with HestiaCP Companion
  7. Migrate HestiaCP accounts
  8. Split one account across multiple users
  9. Configure HestiaCP backups
  10. Optional configuration
  11. Troubleshoot outbound connections (optional)

1. First login

Your provider supplies the server’s IP address and initial username. The examples use debian for the initial account, sysadmin for the permanent administrator, and server.example.com for the new hostname.

Connect from your computer.

ssh debian@203.0.113.10

Before accepting the SSH host key, compare its fingerprint with the one supplied by your provider. If the provider gave you a root login, use it for the steps that require administrative privileges.

On the new server, check the Debian release, CPU architecture, and current user, then open a root shell.

cat /etc/os-release
uname -m
id
sudo -i

Opening a root shell with sudo -i confirms that you have administrative access before you change users or networking. Type exit to return to your ordinary session after the check. In the rest of the guide, run commands prefixed with sudo as your administrative user. Blocks marked as root assume you already have a root shell.

2. Prepare Debian

2.1 APT repositories and base packages

Inspect the package sources configured in your provider’s image.

sudo find /etc/apt/sources.list.d -maxdepth 1 -type f -print
sudo grep -R -nE '^(Types|URIs|Suites|Components|Signed-By):|^deb ' \
  /etc/apt/sources.list /etc/apt/sources.list.d 2>/dev/null || true
apt-cache policy

On Debian 13, enable main, contrib, non-free, and non-free-firmware, along with security updates and, if needed, backports. Keep any provider-specific repositories. A fresh installation could use this DEB822 configuration in /etc/apt/sources.list.d/debian.sources.

Types: deb
URIs: https://deb.debian.org/debian
Suites: trixie trixie-updates
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

Types: deb
URIs: https://security.debian.org/debian-security
Suites: trixie-security
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

Types: deb
URIs: https://deb.debian.org/debian
Suites: trixie-backports
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

Edit the file with sudoedit and remove any duplicate entries from older .list files. Avoid mixing stable, testing, and unstable to obtain a newer package.

sudoedit /etc/apt/sources.list.d/debian.sources
sudo apt update
apt list --upgradable
sudo apt full-upgrade
sudo apt install -y ca-certificates curl wget rsync unzip git jq htop lsof \
  dnsutils tmux pv zstd smartmontools nvme-cli

To install a specific backport, use sudo apt install -t trixie-backports PACKAGE_NAME. You can leave the rest of the system on stable.

If the upgrade installed a new kernel, reboot and reconnect over SSH before installing the panel.

2.2 Locale

SSH sessions can inherit LC_* settings from the client. Programs such as Perl may print warnings if the server lacks the requested locale. Generate the locale your client needs and keep the existing service language unless you want to change it.

For example, an Italian client may need it_IT.UTF-8.

sudo apt install -y locales
sudo sed -i 's/^# *it_IT.UTF-8 UTF-8$/it_IT.UTF-8 UTF-8/' /etc/locale.gen
sudo locale-gen
sudo update-locale LANG=C.UTF-8
locale -a

With C.UTF-8 as the default, server applications use predictable messages and formats, and SSH sessions can still use it_IT.UTF-8. To make Italian the default, use sudo update-locale LANG=it_IT.UTF-8. Leave LC_ALL unset globally. Reconnect and run locale to check the result.

2.3 Time zone and NTP synchronization

The server has two independent time settings.

  • The time zone determines how programs display and interpret local time, including cron jobs and timers.
  • The Network Time Protocol (NTP) synchronizes the server’s clock with external time sources. TLS, logs, authentication, and scheduling depend on an accurate clock.

Set the time zone

For a server administered from Italy, use the regional time zone.

sudo timedatectl set-timezone Europe/Rome
timedatectl

Substitute your own region or use UTC. A region such as Europe/Rome automatically switches between standard and daylight saving time. Avoid a fixed CET offset if you need seasonal changes.

Check for an existing NTP service

timedatectl
systemctl is-active systemd-timesyncd.service || true
systemctl is-active chrony.service || true
systemctl is-active ntpsec.service || true

If an NTP daemon is already running and System clock synchronized reads yes, keep the existing service. For Chrony, check chronyc tracking and chronyc sources -v.

Install an NTP service if needed

On a server without an NTP service, install and enable systemd-timesyncd.

sudo apt install -y systemd-timesyncd
sudo systemctl enable --now systemd-timesyncd.service
sudo timedatectl set-ntp true

If another NTP daemon is already installed, keep it or plan how to replace it. Run only one service to synchronize the clock.

Verify synchronization

timedatectl
timedatectl timesync-status

The second command is specific to systemd-timesyncd. A freshly booted server may need a little time to synchronize. Look for System clock synchronized: yes, NTP service: active, and normally RTC in local TZ: no. If synchronization fails, check the log.

sudo journalctl -u systemd-timesyncd -b --no-pager

Check that the provider’s firewall allows the daemon to reach its time sources, usually on outbound UDP port 123.

2.4 Configure system DNS and disable LLMNR

Processes on the server use the system DNS resolvers to look up names. Hestia manages the public DNS records for hosted domains separately. First find out what manages /etc/resolv.conf.

readlink -f /etc/resolv.conf
cat /etc/resolv.conf
systemctl is-active systemd-resolved || true
ip -br addr
ip route

If systemd-resolved is active, the following override selects Cloudflare’s IPv4 resolvers and disables local multicast name resolution (LLMNR and multicast DNS), which a public server normally has no use for.

sudo install -d /etc/systemd/resolved.conf.d
sudo tee /etc/systemd/resolved.conf.d/90-server-dns.conf >/dev/null <<'CONF'
[Resolve]
DNS=1.1.1.1 1.0.0.1
FallbackDNS=9.9.9.9 149.112.112.112
LLMNR=no
MulticastDNS=no
CONF
sudo systemctl restart systemd-resolved
resolvectl status
resolvectl query example.com

FallbackDNS applies when no other DNS information is available. An individual Cloudflare query failure may never trigger it. The system may continue using per-interface resolvers supplied by DHCP. To use only your chosen servers, configure the active network manager to ignore DNS settings from DHCP. With Netplan’s networkd renderer, for example, consider adding dhcp4-overrides: {use-dns: false} to the existing configuration, along with its IPv6 equivalent if applicable. Make sure you have a recovery console before replacing a remote server’s network configuration.

If the server uses another network manager, configure its resolvers there, whether it uses ifupdown, NetworkManager, networkd, or a static file. Check how the provider manages that file before replacing it, and avoid enabling a local resolver that would conflict with Hestia’s DNS service later.

Check name resolution independently with both commands.

dig example.com
getent ahosts example.com

A resolver reached over IPv4 can return IPv6 addresses in AAAA records. Using IPv4 for DNS leaves IPv6 available.

2.5 Prefer IPv4 for outbound connections (optional)

The transport used for a DNS query does not determine the address family used for the subsequent connection. If an external API is unreliable over IPv6, compare the two families before changing address selection.

Start with the comparison tests in chapter 11. If only IPv6 repeatedly times out, check the address, routes, and firewall. Preferring IPv4 can work around the problem while you investigate its cause.

For programs that use glibc’s getaddrinfo(), set the precedence table in /etc/gai.conf. Even a single precedence rule replaces the whole default table. Preserve the other glibc entries and raise only the precedence of IPv4-mapped addresses. If a custom table already exists, edit it manually to avoid defining a second one.

sudo bash <<'SH'
set -euo pipefail
CONF=/etc/gai.conf
test -f "$CONF"
if grep -Eq '^[[:space:]]*precedence[[:space:]]+' "$CONF"; then
    echo 'Custom precedence rules already exist. Review them manually.'
    exit 1
fi
cp -a "$CONF" "$CONF.bak.$(date +%Y%m%d-%H%M%S)"
cat >> "$CONF" <<'EOF'

# Prefer IPv4 over IPv6
precedence ::1/128        50
precedence ::/0           40
precedence 2002::/16      30
precedence ::/96          20
precedence ::ffff:0:0/96 100
EOF
SH
getent ahosts example.com

Repeat the HTTPS test in chapter 11 against the affected service, omitting -4 and -6, and check which address the connection used. Debian needs no reboot, though long-running processes may need a restart to pick up the configuration. To undo the change, restore the saved copy of gai.conf and restart the affected processes.

IPv6, routing, and AAAA records remain available after changing gai.conf. Clients such as libcurl may select an address family independently using Happy Eyeballs or a different resolver. If only one PHP application has the problem, scope the setting to that application. Guzzle accepts force_ip_resolve => 'v4', and PHP cURL accepts CURLOPT_IPRESOLVE with CURL_IPRESOLVE_V4. Avoid disabling IPv6 system-wide without a verified need. gai.conf(5)

3. Administrative account and SSH

Rename the initial Debian account while preserving its user ID (UID), group ID (GID), home directory, SSH keys, and supplementary groups. Do this before installing HestiaCP. The procedure applies to the operating system’s initial account. Do not use it on an account already managed by Hestia.

3.1 Prepare a second administrative login

Use an independent session to rename the account. If the provider’s console gives you root access, use it. Otherwise, create a temporary administrative account and verify that you can sign in over SSH.

From the initial user’s session, inspect the account and sudo configuration. Substitute the provider’s username wherever the example uses debian.

id debian
getent passwd debian
getent group debian
sudo ls -l /etc/sudoers.d
sudo visudo -c

Open a root shell.

sudo -i

If you still need an independent administrative login, run the following as root.

useradd --create-home --user-group --shell /bin/bash setup-admin
install -d -m 700 -o setup-admin -g setup-admin /home/setup-admin/.ssh
install -m 600 -o setup-admin -g setup-admin \
  /home/debian/.ssh/authorized_keys /home/setup-admin/.ssh/authorized_keys
visudo -f /etc/sudoers.d/90-setup-admin

Add the following rule in visudo.

setup-admin ALL=(ALL:ALL) NOPASSWD:ALL

Set the permissions and validate the configuration.

chmod 440 /etc/sudoers.d/90-setup-admin
visudo -c

The copy command assumes the public key is already in the default home directory for debian. If the provider uses a different AuthorizedKeysFile or an external key service, install your own public key for the temporary account. Keep private keys on your computer. Leave SSH password authentication and remote root login disabled if you normally use key-based access.

Open a second terminal on your computer and verify both SSH and administrative access.

ssh setup-admin@203.0.113.10
sudo -n true && echo 'Administrative access verified'

Continue only after both checks succeed. Close the other debian sessions and keep the setup-admin session or root console open.

3.2 Rename the user and move the home directory

Open a root shell from the independent administrative session.

sudo -i

Run the rest of this subsection as root. The example renames debian to sysadmin. Set both names in the variables below.

OLD_USER=debian
NEW_USER=sysadmin
OLD_UID=$(id -u "$OLD_USER")
OLD_GID=$(id -g "$OLD_USER")
OLD_GROUP=$(id -gn "$OLD_USER")
getent passwd "$OLD_USER"
id "$OLD_USER"
getent passwd "$NEW_USER" || true
getent group "$NEW_USER" || true
ls -ld "/home/$OLD_USER"
pgrep -a -u "$OLD_USER" || true

Confirm that the new username and home directory are available. If the initial user still has active sessions, end them from the independent login.

loginctl terminate-user "$OLD_USER"
pgrep -a -u "$OLD_USER" || true

Identify any remaining processes and stop them normally before continuing. Check for cron jobs, user services, systemd lingering, and configuration files that refer to the old username. Record them before the rename and update them afterwards. A newly provisioned server will usually have none.

usermod -l "$NEW_USER" "$OLD_USER"
if [ "$OLD_GROUP" = "$OLD_USER" ]; then
    groupmod -n "$NEW_USER" "$OLD_GROUP"
fi
usermod -d "/home/$NEW_USER" -m "$NEW_USER"
id "$NEW_USER"
getent passwd "$NEW_USER"
ls -ld "/home/$NEW_USER" "/home/$NEW_USER/.ssh"

File ownership follows the numeric UID, which the rename preserves. Renaming a private group also preserves its GID, so a blanket chown -R is unnecessary. The conditional group rename protects shared groups such as users or sudo.

Verify the IDs and check the SSH authorized keys file.

test "$(id -u "$NEW_USER")" = "$OLD_UID" && echo 'UID preserved'
test "$(id -g "$NEW_USER")" = "$OLD_GID" && echo 'GID preserved'
stat "/home/$NEW_USER/.ssh/authorized_keys"

3.3 Restore sudo and verify the permanent login

Renaming the account leaves any sudoers rules that name the old user pointing to the old name. The example grants the administrator passwordless sudo, which the migration scripts also use. If your policy requires a sudo password, keep that policy and perform the privileged steps manually.

As root, open a dedicated sudoers file.

visudo -f /etc/sudoers.d/90-sysadmin

Add this rule, substituting the name you chose.

sysadmin ALL=(ALL:ALL) NOPASSWD:ALL
chmod 440 /etc/sudoers.d/90-sysadmin
visudo -c

Check /etc/sudoers.d/ for the old username, especially in 90-cloud-init-users if present. If the system uses cloud-init, also check the user definition in /etc/cloud/cloud.cfg and its drop-ins. Edit only the relevant entries, preserving other rules in the same file. Avoid running cloud-init clean on a configured server.

Open a third connection from your computer.

ssh sysadmin@203.0.113.10
id
sudo -n true && echo 'NOPASSWD OK'
sudo visudo -c

Once these checks pass, use visudo to remove the rule dedicated to debian if you no longer need it. Check any SSH AllowUsers or AllowGroups directives before reloading the SSH configuration.

When the permanent login works, close the temporary session. From the new administrator’s account, remove the emergency account if you created it specifically for this rename.

# Only if you created setup-admin specifically for this procedure.
sudo loginctl terminate-user setup-admin
sudo userdel -r setup-admin
sudo rm /etc/sudoers.d/90-setup-admin
sudo visudo -c

For automation, sudo -n true checks whether sudo can run a command without prompting. Under some NOPASSWD configurations, sudo -v can still ask for a password. The migration script uses sudo -n true.

3.4 SSH access from your computer

If you want short names for the servers, add aliases to ~/.ssh/config on your computer.

Host new-server
    HostName 203.0.113.10
    User sysadmin

Host old-server
    HostName old.example.com
    User root

Once DNS is ready, set HostName to the server’s fully qualified domain name (FQDN). The new server can keep remote root login disabled when sysadmin has sudo access. SSH access to the old server is covered in the migration chapter.

3.5 Persistent journals and user service logs

If you manage rootless containers, workers, or timers through systemctl --user, give each account access to its own service logs while keeping other users’ logs private.

For a user unit, such as one installed in ~/.config/systemd/user/, run these commands as its owner.

systemctl --user list-units --type=service
journalctl --user -n 20 --no-pager
journalctl --user -u service-name.service -f

For system units in /etc/systemd/system/, use sudo journalctl -u service-name.service, even if the unit sets User=.... The manager that starts the unit determines where to look for its logs.

If journalctl --user cannot open a journal, check that the journal is persistent and split by UID. Apply this global override if the current configuration needs either setting.

sudo install -d /etc/systemd/journald.conf.d
sudo tee /etc/systemd/journald.conf.d/90-user-journals.conf >/dev/null <<'CONF'
[Journal]
Storage=persistent
SplitMode=uid
SystemMaxUse=1G
CONF
sudo mkdir -p /var/log/journal
sudo systemd-tmpfiles --create --prefix /var/log/journal
sudo systemctl restart systemd-journald
sudo journalctl --flush
sudo journalctl --disk-usage

SystemMaxUse=1G allocates a total budget for the persistent journal. Choose it according to the log volume and disk space across all users. SplitMode=uid creates separate journals for ordinary users, with system UIDs handled separately. After one of the user’s units writes new logs, check them from that user’s session.

journalctl --user -n 20 --no-pager

Keep web accounts out of the adm and systemd-journal groups, which would grant access to unrelated system logs. Lingering lets a user’s service manager run without an active login. It is covered in the Podman chapter. journald.conf(5)

4. Install and configure HestiaCP

Start with a clean Debian installation. Generate a fresh installation command so you can select the components and PHP versions your sites actually need. An older command may contain obsolete options. HestiaCP installation command generator

Use these settings to reproduce the server configuration in this guide.

Installer option Setting
Hostname The permanent FQDN, such as server.example.com
Panel username A panel administrator separate from sysadmin, such as hestia
Port Your preferred panel port. Hestia defaults to 8083.
Apache Enable it alongside the Nginx reverse proxy.
PHP-FPM / MultiPHP Enable it and include the PHP versions the sites require.
MariaDB Enable it.
MySQL 8 / PostgreSQL Leave disabled unless an application requires one.
BIND Enable it if the server will host DNS zones.
Exim / Dovecot Enable them if the server will host email or retain migrated mailboxes.
Sieve / ClamAV / SpamAssassin Select according to mail requirements and available resources.
FTP Enable only if required. Prefer SFTP when clients support it.
Firewall / Fail2Ban Enable them and keep SSH and other required ports reachable.
Quota Enable if the filesystem supports quotas and the hosting plans require them.

Confirm the administrator’s email address. Keep real passwords out of documentation and repositories. If you choose an unattended installation, protect the generated command and the resulting credentials.

On the new server, enter a root shell, download the installer, and inspect its options.

sudo -i
cd /root
wget https://raw.githubusercontent.com/hestiacp/hestiacp/release/install/hst-install.sh
bash hst-install.sh -h

Run the command from the generator with your chosen options. Alternatively, run bash hst-install.sh for an interactive installation with the defaults. Choose one installation method. Follow the installer’s prompts and reboot when requested. Check the provider’s firewall as well, especially the rules for the SSH and Hestia panel ports.

See Hestia’s Getting Started guide.

4.1 Hostname and public DNS

Set the permanent hostname in the installer if possible. To change it after installation, use Hestia’s native command so that the panel-managed configuration is updated too. Running hostnamectl set-hostname alone leaves that configuration behind.

sudo /usr/local/hestia/bin/v-change-sys-hostname server.example.com
hostnamectl
hostname -f
cat /etc/hostname
cat /etc/hosts

A typical Debian /etc/hosts file can resolve the hostname locally with the following entries. Preserve any other entries you need and check whether your Hestia installation requires different settings.

127.0.0.1 localhost
127.0.1.1 server.example.com server

Configure these DNS records for the new host.

Record Name Example value
A server.example.com 203.0.113.10
AAAA server.example.com The server’s global IPv6 address, only if configured and reachable
PTR The new server’s IP address server.example.com, set through the IP provider

The reverse DNS (PTR) record is particularly important for outbound mail. Give the new server a different hostname while the old server still uses its name for SSH or email.

dig +short A server.example.com
dig +short AAAA server.example.com
dig -x 203.0.113.10 +short

Once the name resolves correctly, check that port 80 is reachable for ACME certificate validation. Request the panel certificate if one has yet to be issued.

sudo /usr/local/hestia/bin/v-add-letsencrypt-host

Inspect the certificate on the panel’s actual port. This example uses 8083.

openssl s_client -connect server.example.com:8083 \
  -servername server.example.com </dev/null 2>/dev/null \
  | openssl x509 -noout -subject -ext subjectAltName

Sign in at https://server.example.com:8083, substituting your chosen port, and check the panel. If you installed Exim, also check which hostname it uses for mail.

sudo cat /etc/mailname
sudo exim4 -bP primary_hostname

4.2 Web servers starting before DHCP assigns an address

Use this fix only if Apache and Nginx fail at boot because DHCP has yet to assign the IPv4 address. Look for a bind error such as Cannot assign requested address, followed by a successful manual restart. A port conflict needs a different fix.

Identify the public interface and network manager, then inspect the boot sequence.

ip -br addr
ip -4 route
systemctl is-active systemd-networkd || true
sudo journalctl -b -u systemd-networkd -u systemd-networkd-wait-online \
  -u nginx -u apache2 --no-pager -o short-monotonic

If systemd-networkd manages the interface and the boot log confirms that the startup check completes before IPv4 is ready, add an explicit IPv4 check to both services. Replace eno1 with the actual public interface. Locate the wait-online binary before creating the overrides.

ls -l /usr/lib/systemd/systemd-networkd-wait-online \
      /lib/systemd/systemd-networkd-wait-online
/usr/lib/systemd/systemd-networkd-wait-online --help

On Debian 13 with systemd-networkd, first confirm that the binary supports the options below.

sudo bash <<'SH'
set -euo pipefail
IFACE=eno1
WAIT=/usr/lib/systemd/systemd-networkd-wait-online
ip link show "$IFACE" >/dev/null
[[ -x "$WAIT" ]]
for service in nginx apache2; do
    dir="/etc/systemd/system/${service}.service.d"
    mkdir -p "$dir"
    cat > "$dir/10-wait-ipv4.conf" <<CONF
[Service]
ExecStartPre=$WAIT --interface=$IFACE:routable --ipv4 --timeout=90
CONF
done
systemctl daemon-reload
SH

Check the configuration and test the restart. Restarting briefly interrupts the hosted sites, so do it before migrating them or during a maintenance window.

systemctl show nginx apache2 -p ExecStartPre
sudo nginx -t
sudo apachectl configtest
sudo systemctl restart apache2 nginx
systemctl is-active nginx apache2

Check both services again after a scheduled reboot. If you use another network manager, use its wait-online mechanism. Avoid applying net.ipv4.ip_nonlocal_bind=1 as a general fix. It changes binding behavior system-wide and can leave an incorrect network or Hestia IP configuration unresolved.

4.3 Resolve the Apache ServerName warning

If apachectl configtest reports AH00558 because Apache cannot determine a global FQDN, check which configuration files it includes.

sudo apachectl -t -D DUMP_INCLUDES

On a Hestia Nginx and Apache installation that loads /etc/apache2/conf.d/, set a global ServerName there.

sudo install -d /etc/apache2/conf.d
echo 'ServerName server.example.com' \
  | sudo tee /etc/apache2/conf.d/servername.conf
sudo apachectl configtest
sudo systemctl reload apache2

Use the actual hostname. If your installation loads conf-enabled, use Debian’s a2enconf mechanism. Define the global directive only once. The warning usually allows Apache to start, but the final configuration test should report Syntax OK.

4.4 PHP versions and HestiaCP Companion

Before moving the sites, install all required PHP versions through Hestia and check which version each site selects. The command-line interpreter (PHP CLI) and PHP-FPM can run different versions. Specify the appropriate executable in scripts and application cron jobs.

ls /etc/php
readlink -f /usr/bin/php
php -v
php --ini
systemctl list-units --all 'php*-fpm.service'

Manage production PHP settings and custom templates in one place with HestiaCP Companion.

Download the hcpc artifact and check the requirements for that release. The release used here requires PHP CLI 8.4 or later, DOM/XML, and OpenSSL. The example assumes you downloaded the file to the administrator’s home directory. HestiaCP Companion releases

php8.4 -v
php8.4 -m | grep -Ei '^(dom|openssl)$'
# If DOM is missing and you use PHP 8.4:
# sudo apt install php8.4-xml
sudo install -m 755 "$HOME/hcpc" /usr/local/bin/hcpc
php8.4 /usr/local/bin/hcpc

Run the guided optimization.

sudo php8.4 /usr/local/bin/hcpc php:optimize

If the first run asks you to address disabled PHP CLI functions, make the indicated change and rerun the command. Review the proposed memory, OPcache, just-in-time compilation (JIT), and realpath cache settings before confirming. Re-enabling exec, proc_open, or similar functions for PHP-FPM makes them available to every site that uses those settings. Keep them disabled unless the sites need them.

Companion manages overrides in conf.d, validates the syntax, and restarts affected PHP-FPM services. Refer to its documentation for options and custom templates. Hestia can overwrite direct edits to its generated files during a rebuild.

Choose the PHP-FPM process manager and worker limits according to each site’s traffic and available memory. A high worker count for every domain can exhaust the server. Inspect pool settings and running processes before migration.

sudo grep -R -nE '^pm\s*=|^pm\.' /etc/php/*/fpm/pool.d/ 2>/dev/null || true
ps -eo pid,rss,args --sort=-rss | grep '[p]hp-fpm' | head -n 20

A dedicated PHP-FPM pool for a busy domain (optional)

Keep using HestiaCP Companion for shared settings. If one domain needs a different worker limit, create a dedicated backend template through Companion if your release supports it. Run php8.4 /usr/local/bin/hcpc to see its commands. Alternatively, copy the native Hestia template and edit the copy.

This PHP 8.4 example uses ondemand mode and a limit of 100 processes for a domain that needs high concurrency. Size the limit for the individual site before applying it.

sudo bash <<'SH'
set -euo pipefail
PHP_VERSION=8.4
MAX_CHILDREN=100
MAX_REQUESTS=10000
IDLE_TIMEOUT=5s
DIR=/usr/local/hestia/data/templates/web/php-fpm
SRC="$DIR/PHP-${PHP_VERSION/./_}.tpl"
DST="$DIR/ondemand${MAX_CHILDREN}-PHP-${PHP_VERSION/./_}.tpl"
test -f "$SRC" || { echo 'Source template missing'; exit 1; }
test ! -e "$DST" || { echo 'Destination template already exists. Refusing to overwrite it.'; exit 1; }
for key in pm pm.max_children pm.max_requests pm.process_idle_timeout; do
    grep -Eq "^[[:space:]]*${key//./[.]}[[:space:]]*=" "$SRC" || {
        echo "Missing directive: $key"; exit 1;
    }
done
cp -a "$SRC" "$DST"
sed -i -E \
    -e 's/^[[:space:]]*pm[[:space:]]*=.*/pm = ondemand/' \
    -e "s/^[[:space:]]*pm\.max_children[[:space:]]*=.*/pm.max_children = $MAX_CHILDREN/" \
    -e "s/^[[:space:]]*pm\.max_requests[[:space:]]*=.*/pm.max_requests = $MAX_REQUESTS/" \
    -e "s/^[[:space:]]*pm\.process_idle_timeout[[:space:]]*=.*/pm.process_idle_timeout = $IDLE_TIMEOUT/" \
    "$DST"
grep -E '^pm( =|\.max_children|\.max_requests|\.process_idle_timeout)' "$DST"
SH

In the panel, open Web → Edit Domain → Backend Template PHP-FPM, select ondemand100-PHP-8_4, and save. The NAME-PHP-X_Y.tpl naming pattern lets Hestia identify the PHP version. Substitute the real domain and check that the generated pool has the expected settings.

sudo grep -E '^pm( =|\.max_children|\.max_requests|\.process_idle_timeout)' \
  /etc/php/8.4/fpm/pool.d/app.example.com.conf
sudo /usr/sbin/php-fpm8.4 -t
systemctl is-active php8.4-fpm

pm.max_children limits the number of processes in one pool. pm.max_requests recycles each worker after it has served the configured number of requests. In ondemand mode, pm.process_idle_timeout determines how long an idle worker lives. This mode suits servers with many intermittently busy domains. For steady traffic, consider dynamic if repeatedly spawning workers adds latency.

Size the pool using the workers’ actual memory use, expected concurrency, CPU core count, and available database connections. Prefer proportional set size (PSS) or private memory when measuring workers, since resident set size (RSS) includes shared memory. Check for signs of saturation.

sudo journalctl -u php8.4-fpm --since '24 hours ago' --no-pager \
  | grep -Ei 'max_children|seems busy|slow|warning' || true
sudo ps -eo pid,user,rss,args --sort=-rss | grep '[p]hp-fpm' | head -n 25

If PHP-FPM warnings do not reach the journal, check the error log configured for PHP-FPM. Include custom templates in your configuration backups. Recreate them on the new host before restoring domains that depend on them, and compare them with the native templates after upgrades. HestiaCP web templates

4.5 Upgrade to MariaDB 12.3

If Hestia installed MariaDB 11.8 and you want the 12.3 branch, upgrade before migrating application databases. If Hestia already installed 12.3, skip to the verification step. For any other starting version, follow MariaDB’s documented upgrade path for that version.

Check the installed version, repositories, and available disk space.

mariadb --version
sudo mariadb -e 'SELECT VERSION();'
apt-cache policy mariadb-server mariadb-client
df -h /var/lib/mysql /root
sudo grep -R -nEi 'mariadb|maria-db' \
  /etc/apt/sources.list /etc/apt/sources.list.d/ 2>/dev/null || true

Confirm that your HestiaCP release and the MariaDB repository for Debian 13 support the target branch. MariaDB’s 11.8 to 12.3 upgrade guide

Back up the server and configure the repository

Even on a fresh installation, Hestia may already have created internal credentials and schemas. Save the APT and MariaDB configurations and a backup compatible with the old version, preferably a consistent server snapshot or a physical MariaDB backup. The logical dump below provides an additional safeguard. Restoring the mysql system database across major versions requires a version-specific procedure.

sudo bash <<'SH'
set -euo pipefail
umask 077
backup_dir=$(mktemp -d /root/mariadb-pre-upgrade.XXXXXXXX)
cp -a /etc/apt/sources.list.d "$backup_dir/"
cp -a /etc/mysql "$backup_dir/"
mariadb-dump --all-databases --single-transaction --quick \
  --routines --events --triggers | zstd -T0 -1 -c > "$backup_dir/all-databases.sql.zst"
zstd -t "$backup_dir/all-databases.sql.zst"
printf 'Backup: %s\n' "$backup_dir"
SH

Keep the applications you plan to migrate off the new database server during preparation. If the databases already serve production traffic, arrange a backup and rollback procedure that covers those applications before proceeding.

Use the official repository setup tool to select the Community 12.3 branch. Download the script first and verify its source and checksum before running it. Check the checksum and available options for the downloaded version in the MariaDB repository setup documentation.

curl -fL https://r.mariadb.com/downloads/mariadb_repo_setup \
  -o /tmp/mariadb_repo_setup
bash /tmp/mariadb_repo_setup --help
sudo bash /tmp/mariadb_repo_setup \
  --mariadb-server-version=mariadb-12.3 \
  --skip-maxscale --skip-tools
sudo apt update
apt-cache policy mariadb-server mariadb-client

Confirm that APT’s candidate is 12.3.x. Check whether an older MariaDB source or APT pin selects another version. Keep the Hestia and PHP repositories and disable the previous MariaDB repository only if it still conflicts.

Upgrade the packages

Simulate the APT transaction first.

sudo apt-get -s install mariadb-server mariadb-client mariadb-backup

Check the proposed changes for removal of Hestia or other required components. The official 11.8 to 12.3 procedure stops MariaDB, removes the old server package while preserving its configuration, and installs packages from the new repository. Simulate the removal separately before running it.

sudo apt-get -s remove mariadb-server

Continue only when the resulting dependencies are compatible with Hestia and the backup is available. If removal would take Hestia components with it, stop and check the procedure supported by your panel version. Avoid forcing the transaction.

sudo systemctl stop mariadb
sudo apt-get remove mariadb-server
sudo apt-get install mariadb-server mariadb-client mariadb-backup
sudo systemctl start mariadb
sudo mariadb-upgrade

Preserve /var/lib/mysql and keep purge, mariadb-install-db, and autoremove out of this sequence. In particular, never initialize an existing instance or run automatic package removal between removal and reinstallation. APT may perform part of the upgrade automatically. Run mariadb-upgrade to confirm completion, and check the official upgrade guide for configuration options removed in the new major version.

Verify the upgrade

sudo mariadb -e 'SELECT VERSION(); SHOW DATABASES;'
sudo systemctl status mariadb --no-pager
sudo journalctl -u mariadb -b --no-pager -n 100
apt-cache policy mariadb-server

Confirm in the panel that Hestia can connect to MariaDB. Before importing real data, use a Hestia account to create a small test database, then remove it through the panel. Preserve the SQL credentials Hestia uses internally.

Memory and InnoDB tuning are covered in the optional configuration chapter.

4.6 Create a dedicated MariaDB administrator

To manage MariaDB from phpMyAdmin or a remote SQL client, create a separate SQL account and preserve the system’s root account settings. The example grants dbadmin global administrative privileges. Reserve it for administration. If access to a few databases is enough, limit the grants accordingly.

Check whether the account already exists.

sudo mariadb -e "SELECT User,Host FROM mysql.user WHERE User='dbadmin';"

Create the account once, from a private administrative session. Save the generated random password in your password manager.

DB_PASS=$(openssl rand -hex 24)
if sudo mariadb <<SQL
CREATE USER 'dbadmin'@'localhost' IDENTIFIED BY '${DB_PASS}';
CREATE USER 'dbadmin'@'127.0.0.1' IDENTIFIED BY '${DB_PASS}';
GRANT ALL PRIVILEGES ON *.* TO 'dbadmin'@'localhost' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'dbadmin'@'127.0.0.1' WITH GRANT OPTION;
SQL
then
    printf 'dbadmin password: %s\n' "$DB_PASS"
fi
unset DB_PASS

Skip CREATE USER for any account that already exists. Keep the password output out of shared logs. Check the grants for both connection methods.

sudo mariadb -e "SHOW GRANTS FOR 'dbadmin'@'localhost';"
sudo mariadb -e "SHOW GRANTS FOR 'dbadmin'@'127.0.0.1';"

To connect from another computer, open an SSH tunnel.

ssh -N -L 13306:127.0.0.1:3306 sysadmin@server.example.com

Point the SQL client at 127.0.0.1:13306 and sign in as dbadmin. For phpMyAdmin, use the endpoint Hestia configured. Keep MariaDB off the public internet and avoid granting access to dbadmin@% for convenience.

5. Rootless Podman and Arcane

Use this chapter if the new server will also run containers. Hestia manages the conventional websites, while the containers run under a separate, unprivileged Linux account. Hestia handles HTTPS for the containerized web services and forwards requests through a reverse proxy.

5.1 Install Podman and Compose

sudo apt update
sudo apt install -y podman podman-docker docker-compose uidmap passt \
  slirp4netns dbus-user-session systemd-container openssl
podman --version
apt-cache policy podman

Check the package names in your configured Debian repositories. podman-docker provides a wrapper for the docker command. It uses Podman underneath. The podman compose command needs a Compose provider. If docker-compose is unavailable or unsuitable for your setup, install podman-compose and check which provider Podman selects. Podman supplies its own socket, so you can skip Docker Engine.

5.2 Create a dedicated account for rootless containers

Run these commands only if the server does not already have an account for containers.

sudo useradd --create-home --user-group --shell /bin/bash containers
sudo passwd -l containers
id containers
sudo grep '^containers:' /etc/subuid /etc/subgid
sudo loginctl enable-linger containers
sudo systemctl start "user@$(id -u containers).service"
loginctl show-user containers -p Linger

Keep the containers account unprivileged. It needs subordinate user and group ID ranges in /etc/subuid and /etc/subgid that do not overlap with other accounts. If either range is missing, inspect both files and assign free ranges with usermod --add-subuids and --add-subgids. Check IDs and ranges locally before reusing values from another server.

Enabling lingering starts the account’s systemd user manager even when nobody is logged in. Open a shell with machinectl to get a session with D-Bus and the correct XDG_RUNTIME_DIR.

sudo machinectl shell containers@

Run the following commands as containers, without sudo, until instructed to switch back.

whoami
echo "$XDG_RUNTIME_DIR"
systemctl --user enable --now podman.socket
systemctl --user is-active podman.socket
podman info --format '{{.Host.Security.Rootless}}'
podman info --format '{{.Store.GraphRoot}}'
podman compose version
podman ps

The rootless socket is at /run/user/UID/podman/podman.sock. Keep it off TCP and restrict access so website accounts cannot use it. When moving volumes between machines, keep a secure record of the user and group IDs and their subordinate mappings.

5.3 Install Arcane with Quadlet

Arcane provides a web interface for managing containers and Compose stacks. Install it as a rootless Quadlet so systemd manages its lifecycle. Anyone with administrative access to the panel can control all containers owned by the containers account. Arcane’s Podman setup guide

As containers, prepare the directories. Generate the encryption key only for a new installation.

mkdir -p ~/.config/containers/systemd ~/stacks
chmod 700 ~/.config/containers/systemd ~/stacks
openssl rand -hex 32 | podman secret create arcane-encryption-key -
podman secret ls

Use the installed version’s podman secret inspect --showsecret option to keep a secure copy of the key off the server. Recovering Arcane from its data volume alone may be impossible without the key. Keep the original key when working with an existing instance.

Create the Quadlet file, setting ARCANE_URL to the public URL you plan to use. This template uses the ARCANE_* environment variables documented by Arcane. For an older release, check the variable names for that version.

ARCANE_URL=https://containers.example.com
cat > ~/.config/containers/systemd/arcane.container <<EOF
[Unit]
Description=Arcane Container Manager
Documentation=https://getarcane.app/docs/podman/setup
Requires=podman.socket
After=podman.socket

[Container]
Image=ghcr.io/getarcaneapp/manager:latest
ContainerName=arcane
Pull=missing
SecurityLabelDisable=true
PodmanArgs=--cgroupns=host
PublishPort=127.0.0.1:3552:3552
Volume=%t/podman/podman.sock:/var/run/docker.sock
Volume=%t/bus:%t/bus
Volume=arcane-data:/app/data
Volume=$HOME/stacks:$HOME/stacks
Secret=arcane-encryption-key,type=mount,target=/run/secrets/arcane-key,mode=0444
User=0:0
UserNS=keep-id
Environment=ARCANE_APP_URL=$ARCANE_URL
Environment=PUID=$(id -u)
Environment=PGID=$(id -g)
Environment=TZ=Europe/Rome
Environment=ARCANE_PROJECTS_DIRECTORY=$HOME/stacks
Environment=ARCANE_ENCRYPTION_KEY_FILE=/run/secrets/arcane-key
Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=%t/bus
HealthCmd=["./arcane","health","--timeout","2s"]
HealthInterval=10s
HealthTimeout=3s
HealthRetries=5
HealthStartPeriod=15s
Notify=healthy

[Service]
Restart=always
TimeoutStartSec=900
TimeoutStopSec=70

[Install]
WantedBy=default.target
EOF

The D-Bus mount and keep-id let Arcane manage the account’s Quadlet units on releases that support this feature. The stacks directory has the same path inside the container and on the host so Compose projects can use it in both places. Arcane listens only on 127.0.0.1. Leave that port closed in the public firewall.

The latest tag starts you on the current release. For a reproducible production deployment, pin a verified tag or digest and schedule updates. This configuration leaves automatic image updates disabled.

Start Arcane and check its status.

systemctl --user daemon-reload
systemctl --user start arcane.service
systemctl --user status arcane.service --no-pager
podman ps
podman inspect arcane --format '{{.State.Health.Status}}'
curl -I http://127.0.0.1:3552

Check that the container reports healthy. If systemd does not generate the unit, check which Quadlet features and options your Podman version supports. Read the boot log with journalctl --user -u arcane.service -b. The Quadlet generator handles the [Install] section of the .container file, so skip systemctl --user enable arcane.service for the generated unit.

Before exposing the panel, retrieve the initial password following the instructions for your release. If your release writes it to /app/data/initial-admin-password, copy it to a private file.

umask 077
podman cp arcane:/app/data/initial-admin-password "$HOME/arcane-initial-password"
chmod 600 "$HOME/arcane-initial-password"

Read the file in a private session, set a strong permanent password, then remove the temporary copy. Chapter 6 puts the panel behind a reverse proxy. To test it first, open a separate session on your administrative workstation and start an SSH tunnel with ssh -N -L 3552:127.0.0.1:3552 sysadmin@server.example.com.

5.4 Start containers after a server reboot

With lingering enabled, the user manager starts Arcane because its Quadlet specifies WantedBy=default.target. Each Compose stack needs its own restart policy, such as restart: unless-stopped, and a working mechanism to restart its containers at boot.

As containers, check the restart service.

systemctl --user status podman-restart.service --no-pager

If your installed version provides the service and it is disabled, enable it.

systemctl --user enable --now podman-restart.service

After a scheduled reboot, check that Arcane and each expected container actually started. Starting Arcane does not guarantee that it will recreate every stack at boot.

6. Set up a reverse proxy with HestiaCP Companion

Hestia can publish a service that listens on a local port while keeping the port itself off the public Internet. Companion generates the Nginx templates, removing the need to maintain a separate hestia-proxy-create script.

Run exit to leave the containers session and return to your administrative account. Check that the service responds on the loopback interface.

curl -I http://127.0.0.1:3552

6.1 Generate the template

Use the Companion installed in section 4.4. The command takes the form reverse-proxy NAME PORT. For Arcane, use port 3552.

sudo php8.4 /usr/local/bin/hcpc reverse-proxy arcane 3552

Companion creates proxy-arcane.tpl and proxy-arcane.stpl to forward traffic to 127.0.0.1:3552, including WebSocket connections. Your panel configuration determines where Companion writes the templates and where you select them.

Web configuration Template directory Panel field
Nginx + Apache /usr/local/hestia/data/templates/web/nginx/ Proxy Template
Standalone Nginx /usr/local/hestia/data/templates/web/nginx/php-fpm/ Web Template

By default, Companion preserves existing files. Check reverse-proxy --help and use --force only when you intend to regenerate the templates. Companion keeps a copy of any files it replaces.

6.2 Create the public domain

  1. Point the A record for containers.example.com at the new server. Add an AAAA record only if the server is reachable over IPv6.
  2. In Hestia, create a dedicated web account for the service or choose an appropriate existing account. Add the domain containers.example.com to it.
  3. Select proxy-arcane under Proxy Template for Nginx + Apache or Web Template for standalone Nginx.
  4. Once you confirm the domain resolves correctly, enable SSL, Let’s Encrypt and the HTTPS redirect.

Check the Nginx configuration and the public service.

sudo nginx -t
curl -I https://containers.example.com

To publish another service that listens on a local port, use its name and port number. This example uses port 18080.

sudo php8.4 /usr/local/bin/hcpc reverse-proxy app 18080

Create the corresponding domain and select proxy-app. Each service needs its own port unless you explicitly configure routing between them. Make changes through the panel and leave the generated virtual host file alone.

Keep application ports on the loopback interface. Protect administrative interfaces with strong authentication, multifactor authentication where available, and access restrictions where appropriate. HTTPS encrypts the connection. The panel still needs its own access controls.

7. Migrate HestiaCP accounts

Once the new server is ready, move accounts from the old Hestia server using its native backup archives. This chapter covers whole accounts. To distribute one account’s sites across several users, see chapter 8.

7.1 Prepare and inventory the account

If you control DNS, lower the time to live (TTL) on the affected records early enough for the previous TTL to expire. Check that the new server supports every required PHP version, template, mail service, DNS configuration and quota. Transfer or regenerate custom templates before restoring any accounts.

Set up SSH access from the new server to the old one. The scripts run as a regular administrative user on the new host and use root on the old one to create Hestia backups. Use a dedicated migration key and remove its authorization from the source when you finish.

On the new server, generate the key as sysadmin.

mkdir -p -m 700 ~/.ssh
ssh-keygen -t ed25519 -f ~/.ssh/hestia-migration -C hestia-migration

Choose an unused filename so you preserve any existing key. If the key has a passphrase, load it into an SSH agent. Using an existing administrative session on the old server, add only the public key from ~/.ssh/hestia-migration.pub to the authorized keys. If the old host disallows root SSH login, keep that restriction. Have an administrator with sudo create native backups and transfer them manually, or adapt the script to that access model.

Add this entry to ~/.ssh/config on the new server.

Host migration-source
    HostName old.example.com
    User root
    IdentityFile ~/.ssh/hestia-migration
    IdentitiesOnly yes

Verify the source server’s host key on the first connection, then test noninteractive access.

ssh migration-source hostname -f
ssh -o BatchMode=yes migration-source hostname -f

Inventory the source account and check disk space on both servers. The example uses web_site.

ssh migration-source '/usr/local/hestia/bin/v-list-users'
ssh migration-source '/usr/local/hestia/bin/v-list-web-domains web_site'
ssh migration-source '/usr/local/hestia/bin/v-list-databases web_site'
ssh migration-source '/usr/local/hestia/bin/v-list-mail-domains web_site'
ssh migration-source '/usr/local/hestia/bin/v-list-cron-jobs web_site'
ssh migration-source 'df -h /backup /var/lib/mysql'
df -h /home /backup /var/lib/mysql

Also check DNS zones, backup exclusions, mailboxes, files outside public_html, SSH keys, symbolic links, certificates and external services. Hestia does not automatically copy containers, custom systemd units, or queue and cache data outside the backups. Allow disk space for staging, extracting the archives and restoring the databases.

7.2 Choose a migration strategy

A full backup is enough for a static site or a simple account. For a dynamic application, prevent new writes before taking the final backup. Stop cron jobs, workers, webhooks and anything else that produces writes on the old server. Pause mail delivery or plan a final mailbox sync if necessary.

A full restore can recreate and activate cron jobs and other resources on the new server. Account for the effects of running them twice before restoring alongside live production. If you need a preliminary restore while the source stays live, exclude the affected categories and plan a separate cutover. The steps below move the final copy of the account. They provide no ongoing replication.

7.3 Automate an account migration

Run the script below on the new server as a regular administrative user. It requires noninteractive SSH access to the old host using BatchMode, plus rsync and noninteractive sudo on the new host.

The script creates a native backup on the source, identifies the new archive, copies it to a private staging directory, compares SHA-256 checksums and restores the account. It refuses a full restore if an account with the same name already exists on the destination. Chapter 8 covers restores into existing accounts.

cat > ~/hestia-migrate-user.sh <<'SCRIPT'
#!/usr/bin/env bash
set -Eeuo pipefail
umask 077

die() { printf 'ERROR: %s\n' "$*" >&2; exit 1; }
[[ $# == 2 ]] || die 'Usage: hestia-migrate-user.sh SOURCE_SSH_ALIAS USER'
source_host=$1
user=$2
H=/usr/local/hestia/bin
[[ $source_host =~ ^[a-zA-Z0-9][a-zA-Z0-9_.-]*$ ]] || die 'Invalid SSH alias or hostname'
[[ $user =~ ^[a-z][a-z0-9_]*$ ]] || die 'Invalid user name'
(( EUID != 0 )) || die 'Run as the administrative SSH user, not root'
for cmd in ssh rsync sha256sum sudo; do
    command -v "$cmd" >/dev/null || die "$cmd missing"
done
sudo -n true || die 'Passwordless sudo not available'
[[ -x $H/v-restore-user ]] || die 'Hestia restore missing'
if sudo test -e "/usr/local/hestia/data/users/$user/user.conf" || getent passwd "$user" >/dev/null; then
    die 'Destination user already exists; refusing full restore'
fi
ssh_opts=(-o BatchMode=yes -o ConnectTimeout=15)
ssh "${ssh_opts[@]}" "$source_host" 'test -x /usr/local/hestia/bin/v-backup-user'

printf '[1/4] Backing up %s on %s ...\n' "$user" "$source_host"
archive=$(ssh -T "${ssh_opts[@]}" "$source_host" bash -s -- "$user" <<'REMOTE'
set -Eeuo pipefail
name=$1
[[ -f /usr/local/hestia/data/users/$name/user.conf ]] || exit 1
marker=$(mktemp /tmp/hestia-migrate-marker.XXXXXXXX)
trap 'rm -f -- "$marker"' EXIT
/usr/local/hestia/bin/v-backup-user "$name" >&2
mapfile -t candidates < <(find /backup -maxdepth 1 -type f -name "$name.*.tar" -newer "$marker" -printf '%f\n')
(( ${#candidates[@]} == 1 )) || { echo 'Expected exactly one new archive; inspect /backup' >&2; exit 1; }
printf '%s\n' "${candidates[0]}"
REMOTE
)
[[ $archive == "$user".*.tar && $archive =~ ^[a-zA-Z0-9_.-]+$ ]] || die 'Unexpected archive name'
if sudo test -e "/backup/$archive"; then die 'Backup already exists locally'; fi
stage="$HOME/.cache/hestia-migration"
mkdir -p -- "$stage"
chmod 700 -- "$stage"

printf '[2/4] Transferring %s ...\n' "$archive"
rsync -avhP --no-owner --no-group -e 'ssh -o BatchMode=yes -o ConnectTimeout=15' \
    "$source_host:/backup/$archive" "$stage/"
chmod 600 -- "$stage/$archive"
echo '[3/4] Checking SHA-256 ...'
remote_hash=$(ssh "${ssh_opts[@]}" "$source_host" "sha256sum -- '/backup/$archive'" | awk '{print $1}')
local_hash=$(sha256sum -- "$stage/$archive" | awk '{print $1}')
[[ -n $remote_hash && $remote_hash == "$local_hash" ]] || die 'Checksum mismatch'
if ! sudo test -d /backup; then sudo install -d -m 755 /backup; fi
sudo mv -- "$stage/$archive" "/backup/$archive"
sudo chown root:root "/backup/$archive"
sudo chmod 600 "/backup/$archive"

printf '[4/4] Restoring %s ...\n' "$user"
sudo bash -c 'cd / || exit 1; umask 022; exec /usr/local/hestia/bin/v-restore-user "$@"' \
    _ "$user" "$archive"
printf 'Completed: %s\nBackup: /backup/%s\n' "$user" "$archive"
SCRIPT
chmod 700 ~/hestia-migrate-user.sh
bash -n ~/hestia-migrate-user.sh

Start the transfer only when you are ready for the account’s final migration.

bash ~/hestia-migrate-user.sh migration-source web_site

Migrate the remaining accounts one at a time. Avoid concurrent backups of the same account because the script expects exactly one new archive after it creates its marker file. The native backup process can rotate older backups and upload to the remote destination already configured on the source. Matching SHA-256 checksums confirm that the copied bytes match. You still need to check that the backup contains the expected data and can be restored. Read the Hestia logs even if the command succeeds.

7.4 Troubleshoot backups and restores

Permission denied while extracting a tar archive

A failed restore can report these errors.

tar (child): /backup/tmp.*/web/domain.example.com/domain_data.tar.gz: Cannot open: Permission denied
Error: Can't unpack domain.example.com data tarball

The transfer uses umask 077 to keep the archive private. If the restore inherits that mask, Hestia can create intermediate directories owned by root:root with mode 700. The website account cannot traverse those directories during extraction.

The script sets umask 022 only for the Hestia process, keeping the backup files private. Avoid chmod -R 777 on /backup or any home directory.

Working directory permission error

find: Failed to restore initial working directory: /home/sysadmin: Permission denied

Some Hestia commands run as the web account. That account may lack permission to enter the administrator’s home directory where the restore started. Run cd / before invoking Hestia so you can retain the home directory’s permissions.

Once you have verified the archive and placed it in /backup, you can restore it manually.

# Use the actual archive name and check the state of the destination account first.
BKP=web_site.2026-01-01_00-00-00.tar
sudo bash -c 'cd / || exit 1; umask 022; exec /usr/local/hestia/bin/v-restore-user "$@"' \
  _ web_site "$BKP"

An interrupted restore may already have created the account and some of its resources. A second full restore could overwrite data you need. Inventory what exists first, then decide how to start over or restore just the missing resources.

Backup fails for a mail domain with no mailboxes

On some older releases, a backup may fail with this error.

tar: *: Cannot stat: No such file or directory

On the old server, check that the mail domain has no mailboxes. Inspect the backup loop to confirm it caused the error, and rule out missing files belonging to an actual mailbox.

sudo /usr/local/hestia/bin/v-list-mail-accounts web_site example.com
sudo ls -la /home/web_site/mail/example.com/
sudo grep -n -A4 -B4 'for account in \*; do' /usr/local/hestia/bin/v-backup-user

Upgrade to a release with the fix if possible. You can exclude the mail domain from the backup only if you can afford to lose its configuration. As a last resort, patch the old script locally. First confirm that the pattern occurs exactly once in the affected block and that it lacks a check for an unmatched wildcard. Wait for all active backups to finish and save a copy of the script before editing it.

# On the source server only, after inspecting the code.
FILE=/usr/local/hestia/bin/v-backup-user
# sudo cp -a "$FILE" "$FILE.bak-$(date +%Y%m%d-%H%M%S)"
# sudo sed -i '/^[[:space:]]*for account in \*; do$/a\    [ -e "$account" ] || continue' "$FILE"
# sudo bash -n "$FILE"

The check skips an unmatched * so the script cannot mistake it for a literal mailbox name. The editing commands are commented out intentionally. Verify that your specific release has this bug before changing Hestia’s code.

7.5 Verify the restore and switch DNS

On the new server, list the restored resources and check the web server configuration.

H=/usr/local/hestia/bin
sudo "$H/v-list-web-domains" web_site
sudo "$H/v-list-databases" web_site
sudo "$H/v-list-mail-domains" web_site
sudo "$H/v-list-cron-jobs" web_site
sudo nginx -t
sudo apachectl configtest

Compare the inventory with the old server. Check files, ownership, PHP versions, SQL credentials, certificates, extensions and any external services the account needs. Make sure cron jobs and services run on only one host.

To test the new server before changing public DNS, run this command from your workstation.

curl -I --resolve example.com:443:203.0.113.10 https://example.com/

--resolve directs the request to the new IP address while preserving the hostname used for TLS and HTTP. For the final test, leave certificate verification enabled by omitting -k. If the certificate fails validation, resolve the issue before proceeding. If HTTPS is unavailable initially, start with HTTP and verify certificate issuance at cutover. While the old site is live, limit tests to operations without real side effects.

Once you have verified the final copy, update the A and AAAA records and any relevant MX or NS records. For mail, check reverse DNS (PTR), SPF, DKIM, DMARC, TLS, the mailboxes and their most recent messages. Switch name servers or MX records only after the corresponding service is ready. During DNS propagation, keep the old server read-only or in maintenance mode to prevent further writes to the migrated data.

Keep the source server and the archives after cutover. If the new server has already accepted writes, reconcile the changes before directing traffic back to the old server or those writes may be lost.

8. Split one account across multiple users

Splitting sites that share a Hestia account lets you manage permissions, quotas, backups and administration separately. Take one archive of the old account and restore selected resources into each new account.

8.1 Plan the new accounts

Decide which sites, databases and mail domains belong to each new user. In this example, web_shared hosts several independent applications.

New user Web domains Mail domains Source database
web_blog blog.example.com None web_shared_blog
web_shop shop.example.com, static.example.com example.com web_shared_shop

Check whether any applications you plan to separate share databases or files. You may need to reconfigure sites that depend on the same resources before splitting them. Check cron jobs and absolute paths too.

In the Hestia panel on the new server, create the destination accounts with suitable packages, passwords, quotas and permissions. Leave the domains and databases for the restore to create unless you have specifically planned a merge. If some sites will keep the original account name, include that account as a separate destination in your plan.

8.2 Create and transfer a single backup

Freeze writes on the old account and create one full backup. Skip the full-restore script from chapter 7 for this procedure.

On the new server, use the migration-source SSH alias you configured earlier.

ssh migration-source '/usr/local/hestia/bin/v-backup-user web_shared'
ssh migration-source 'ls -lht /backup/web_shared.*.tar'

Identify the archive you just created. Replace the example value of BKP with its exact filename.

BKP=web_shared.2026-01-01_00-00-00.tar
(
    set -euo pipefail
    umask 077
    stage="$HOME/.cache/hestia-migration"
    mkdir -p "$stage"
    chmod 700 "$stage"
    [[ $BKP =~ ^web_shared\.[a-zA-Z0-9_.-]+\.tar$ ]]
    rsync -avhP --no-owner --no-group \
        "migration-source:/backup/$BKP" "$stage/"
    chmod 600 "$stage/$BKP"
    SRC=$(ssh migration-source "sha256sum '/backup/$BKP'" | awk '{print $1}')
    DST=$(sha256sum "$stage/$BKP" | awk '{print $1}')
    [[ -n $SRC && $SRC == "$DST" ]]
    if sudo test -e "/backup/$BKP"; then
        echo 'Local archive already exists' >&2
        exit 1
    fi
    sudo mv -- "$stage/$BKP" /backup/
    sudo chown root:root "/backup/$BKP"
    sudo chmod 600 "/backup/$BKP"
    echo 'SHA-256 OK'
)

Check which categories the archive contains. Use sudo tar -tf "/backup/$BKP" to list its contents if needed. Keep the archive and any extracted data out of public directories.

8.3 Restore selected resources

Hestia’s command-line interface accepts the following arguments. Hestia CLI reference

v-restore-user USER BACKUP [WEB] [DNS] [MAIL] [DB] [CRON] [UDIR] [NOTIFY]

For traditional backup archives, no skips a category, a comma-separated list selects specific resources, and '*' selects everything in the category. Quote wildcards and verify how your installed version handles them. Specify databases by the names in the source archive.

With BKP still set to the correct filename, define this helper in your administrative shell on the new server.

restore_selected() {
    local user="$1" web="$2" mail="$3" db="$4"
    sudo bash -c 'cd / || exit 1; umask 022; exec /usr/local/hestia/bin/v-restore-user "$@"' \
      _ "$user" "$BKP" "$web" no "$mail" "$db" no no
}

The function skips DNS, cron and the source user’s general directories so they are not copied into every new account. Restore those resources only where needed. For the accounts in the table above, run the following commands.

restore_selected web_blog 'blog.example.com' no 'web_shared_blog'
restore_selected web_shop 'shop.example.com,static.example.com' 'example.com' 'web_shared_shop'

Restore one account at a time and stop if a command fails. Hestia may change the SQL name to use the new account’s prefix, so verify the database names and credentials after the restore. Restore each mail domain into only one account. If Hestia manages your DNS, recreate or restore each zone in its intended account and avoid activating conflicting records.

8.4 Update application configuration and verify the split

H=/usr/local/hestia/bin
for u in web_blog web_shop; do
    echo "=== $u ==="
    sudo "$H/v-list-web-domains" "$u"
    sudo "$H/v-list-databases" "$u"
    sudo "$H/v-list-mail-domains" "$u"
    sudo "$H/v-list-cron-jobs" "$u"
done
sudo "$H/v-list-mail-accounts" web_shop example.com
sudo nginx -t
sudo apachectl configtest

Update .env files, symbolic links, absolute paths and database credentials wherever applications reference the old account. Use the database names and usernames Hestia actually shows. Avoid a global sed replacement across the code. Check who owns the restored files and verify that the new users cannot access each other’s private data. Recreate account-specific cron jobs and services under the correct new user, checking for duplicates.

Complete the HTTP, SQL, mail and DNS checks from section 7.5 before moving traffic. Keep the original backup until you have verified every destination. The source account can stay in place throughout the restore.

9. Configure HestiaCP backups

Set up ongoing backups after migration. Remove any temporary backup exclusions you used for the transfer. Use Hestia’s native backups for sites, databases and mail. Applications outside the panel need a separate backup strategy beyond the scope of this guide.

9.1 Choose a backup frequency for each account

To give accounts different schedules, replace the global v-backup-users cron job with per-user entries that call v-schedule-user-backup. If the existing global schedule meets your needs, keep it.

On installations that run panel cron jobs as hestiaweb, open Server → Panel Cronjobs. The hestiaweb system account runs these jobs. The panel administrator signs in as hestia, admin or the name you chose during installation.

Check your installation before editing the schedule.

getent passwd hestiaweb
sudo crontab -u hestiaweb -l
sudo ls -l /etc/cron.d/
sudo /usr/local/hestia/bin/v-list-users list

If your version stores the global cron job elsewhere, locate and edit it there. Disable v-backup-users (or the global job for your chosen backend) only after setting up the new schedules. Keep the internal v-update-sys-queue backup job active. It processes the backup queue. Preserve the rest of Hestia’s crontab.

These example schedules use traditional backups.

Account type Frequency Cron expression
Standard sites Sunday at 03:00 0 3 * * 0
Frequently updated sites Monday and Thursday at 04:00 0 4 * * 1,4
Critical, frequently changing data Daily at 05:00 0 5 * * *

Choose a schedule based on how much recent data you can afford to lose, how long backups take and how much space they require. Two weekly runs spaced three and four days apart give a more predictable interval than */3 in the day-of-month field.

9.2 Add schedules in Panel Cronjobs

Use the panel to add entries for your actual accounts. If your version stores these jobs in the hestiaweb crontab, you can also edit it directly.

sudo crontab -u hestiaweb -e

Add entries like these, keeping the rest of the crontab intact.

# Weekly backup - Sunday 03:00
0 3 * * 0 sudo /usr/local/hestia/bin/v-schedule-user-backup web_blog

# Twice-weekly backup - Monday and Thursday 04:00
0 4 * * 1,4 sudo /usr/local/hestia/bin/v-schedule-user-backup web_site

# Daily backup - 05:00
0 5 * * * sudo /usr/local/hestia/bin/v-schedule-user-backup web_shop

v-schedule-user-backup queues the work. This avoids starting several v-backup-user processes in parallel. Check that Hestia’s sudo rules allow the system account to run the intended command. Keep arbitrary sudo privileges out of web accounts. If you use Restic, check the corresponding scheduling command for your installed version.

Check the active entries and confirm the cron daemon is running.

sudo crontab -u hestiaweb -l | grep -E 'v-update-sys-queue backup|v-schedule-user-backup|v-backup-users'
systemctl is-active cron

To queue a test backup manually, use an existing account.

sudo /usr/local/hestia/bin/v-schedule-user-backup web_blog
sudo /usr/local/hestia/bin/v-list-user-backups web_blog

The second command lists the archives already available. A queued backup may still be waiting or running. Check the result after processing finishes and read Hestia’s logs. Stagger the schedules if backups interfere with other work.

9.3 Set retention and keep off-server copies

Hestia packages express retention as a count of archives. Four weekly backups normally give you four restore points, and seven daily backups give you seven. Use actual compressed backup sizes and the frequency of data changes to choose how much space to allocate and how many archives to keep.

sudo /usr/local/hestia/bin/v-list-user-backups web_blog
sudo du -sh /backup
df -h /backup

Configure an external destination as well. Losing the disk or the server would also destroy backup copies stored only on that machine. Choose a backend your Hestia version supports, then test uploads, retention and restores against that destination. Hestia’s Backup & Restore guide

If you use traditional archives and want another copy managed separately, rclone can transfer complete archives to an S3-compatible service, pCloud or another supported remote. Install it and configure the remote under the account that will run the transfers.

sudo apt install -y rclone
sudo rclone config
sudo rclone listremotes
sudo rclone lsd remote:

To copy a completed archive manually, replace remote: and the filename in this example.

sudo rclone copyto /backup/web_blog.2026-01-01_00-00-00.tar \
  remote:backups/server/web_blog.2026-01-01_00-00-00.tar --progress

Use rclone sync only if you have defined a deletion policy. It can delete files from the remote. Keep the rclone configuration file and tokens private. If you automate transfers, start them only after the backup completes successfully. Test at least one restore in an isolated environment with production cron jobs and webhooks disabled.

10. Optional configuration

Once the accounts are running on the new server, use its available memory, actual workload and monitoring needs to decide which of these changes make sense. They can all wait until after the migration.

10.1 Tune MariaDB

Let the migrated sites run through a representative period of traffic before tuning MariaDB. It shares memory, CPU and storage with Nginx, Apache, PHP-FPM, caches, mail services and containers. The InnoDB buffer pool accounts for only part of MariaDB’s memory use.

Collect baseline measurements

free -h
sudo ps -C mariadbd -o pid,rss,%cpu,args
sudo mariadb -e "SHOW GLOBAL VARIABLES WHERE Variable_name IN (
 'innodb_buffer_pool_size','innodb_log_file_size','innodb_flush_log_at_trx_commit',
 'innodb_flush_neighbors','innodb_io_capacity','innodb_io_capacity_max',
 'table_definition_cache','table_open_cache','skip_name_resolve',
 'max_connections','log_bin','sync_binlog','bind_address','max_allowed_packet');"
sudo mariadb -e "SHOW GLOBAL STATUS WHERE Variable_name IN (
 'Uptime','Threads_connected','Max_used_connections','Slow_queries',
 'Innodb_buffer_pool_read_requests','Innodb_buffer_pool_reads','Innodb_log_waits');"
sudo mariadb -e "SELECT ENGINE, COUNT(*) AS tables_count,
 ROUND(SUM(DATA_LENGTH+INDEX_LENGTH)/POWER(1024,3),2) AS size_GiB
 FROM information_schema.TABLES WHERE ENGINE IS NOT NULL GROUP BY ENGINE;"
lsblk -d -o NAME,SIZE,ROTA,MODEL

Run MySQLTuner from a trusted source, such as the Debian package if available.

apt-cache policy mysqltuner
sudo apt install mysqltuner
sudo mysqltuner

If you need a newer release, use the official MySQLTuner repository. Review its suggestions against your measurements before applying them. Even when the full dataset is much larger than the buffer pool, the pages your applications access regularly may fit comfortably. Check uptime, available memory, peak connections, physical reads, slow queries, log waits and pressure on the table definition cache.

Size InnoDB and its caches

On a shared Hestia server, consider 20–40% of total RAM as an initial range for the buffer pool. Measure what the other services use at the same time.

Total RAM Example starting buffer pool
8 GiB 2 GiB
16 GiB 4 GiB
32 GiB 8 GiB
64 GiB 16 GiB

For example, a 64 GiB host with roughly 17 GiB of InnoDB data and indexes and ample memory free during peak traffic could move from 16 GiB to 24 GiB, or to 28 GiB if measurements justify it. With a hit rate already around 99.6%, the increase may make little difference.

Setting What to measure
innodb_buffer_pool_size Working set, available RAM and physical reads.
innodb_flush_neighbors Consider 0 on SSD or NVMe storage. InnoDB may already ignore the setting when it detects an SSD.
innodb_io_capacity Start conservatively and measure I/O and flushing. A capable NVMe device might justify 1000.
table_definition_cache Check the number of tables and pressure on the cache. For a server with hundreds of tables, 1024 is one example.
max_connections Use the measured peak. Keep the existing value if it already has enough headroom.
innodb_log_file_size Check write volume, checkpoint activity and support in your installed version.
Query cache Measure the benefit for your workload before enabling it.

If you already use skip-name-resolve, keep it enabled to avoid DNS lookups during SQL connections. If it is disabled, first inspect the hosts associated with database accounts.

sudo mariadb -e 'SELECT User,Host FROM mysql.global_priv ORDER BY User,Host;'

Before enabling the setting, migrate accounts that depend on DNS hostnames to compatible host rules. Avoid indiscriminately replacing hosts with %. MariaDB accepts localhost and distinguishes it from a TCP connection to 127.0.0.1.

Apply a local configuration

Put your overrides in a separate file to preserve the Debian and Hestia configuration. Look for existing overrides for the same parameters and confirm that your MariaDB version supports each variable. This example assumes 64 GiB of RAM, SSD or NVMe storage, and enough memory for the other services. Adjust the values before running it on a different server. The example leaves authentication settings alone pending the account check above.

sudo bash <<'SH'
set -euo pipefail
CONF=/etc/mysql/mariadb.conf.d/99-local-tuning.cnf
if [ -f "$CONF" ]; then
    cp -a "$CONF" "$CONF.bak.$(date +%Y%m%d-%H%M%S)"
fi
cat > "$CONF" <<'EOF'
[mysqld]
innodb_buffer_pool_size = 28G
innodb_flush_neighbors = 0
innodb_io_capacity = 1000
table_definition_cache = 1024
EOF
SH

If the accounts are compatible and you want MariaDB to use numeric host addresses without DNS lookups, add skip-name-resolve = ON under [mysqld] with sudoedit. Define it in only one file. Preserve durability settings such as innodb_flush_log_at_trx_commit and sync_binlog when doing general tuning.

Apply the configuration during a maintenance window.

sudo mariadbd --print-defaults
sudo systemctl restart mariadb
sudo systemctl status mariadb --no-pager
sudo journalctl -u mariadb -b --no-pager -n 80
sudo mariadb -e "SHOW GLOBAL VARIABLES WHERE Variable_name IN (
 'innodb_buffer_pool_size','innodb_flush_neighbors','innodb_io_capacity',
 'innodb_io_capacity_max','table_definition_cache','skip_name_resolve');"
sudo mariadb -NBe 'SELECT ROUND(@@innodb_buffer_pool_size/POWER(1024,3),2) AS pool_GiB;'
free -h

Restarting MariaDB interrupts SQL connections. If startup fails, restore the previous override from the backup or, if this file was new, remove just that override. Then restart MariaDB. A configuration error can be rolled back without reinstalling the server or deleting databases. After another representative period of traffic, rerun MySQLTuner and compare hit rate, I/O, memory, connections, swap, warnings and latency. InnoDB system variables

10.2 Monitor the server with Zabbix Agent 2

Install Zabbix Agent 2 on the Debian/HestiaCP host you want to monitor. It connects to an existing Zabbix server or proxy. The central monitoring server, database and web interface run elsewhere. Use active checks, passive checks or both. TLS with a pre-shared key (PSK) authenticates and encrypts the connections without requiring certificates.

Install the repository package and agent

Choose an agent version compatible with your Zabbix server or proxy. This example uses 7.0 LTS on Debian 13. For another release series, select Debian 13 and Agent 2 on the Zabbix download page to generate the current commands.

Run these commands on the Hestia host you want to monitor.

(
    set -e
    TMP=$(mktemp -d)
    trap 'rm -rf "$TMP"' EXIT
    wget -O "$TMP/zabbix-release.deb" \
        'https://repo.zabbix.com/zabbix/7.0/debian/pool/main/z/zabbix-release/zabbix-release_latest_7.0+debian13_all.deb'
    sudo dpkg -i "$TMP/zabbix-release.deb"
    sudo apt update
    apt-cache policy zabbix-agent2
    sudo apt install -y zabbix-agent2 openssl
)

Stop any agent instance the package started automatically before editing its configuration. If the older zabbix-agent is already installed, check that it has released TCP port 10050 before starting Agent 2. Agent 2 is sufficient on a new server.

sudo systemctl stop zabbix-agent2
/usr/sbin/zabbix_agent2 -V
getent passwd zabbix
sudo ss -lntp 'sport = :10050'

Choose the check type and host settings

Example Meaning
server.example.com Technical name of the monitored host in Zabbix. For active checks, it must exactly match the agent’s Hostname.
monitor.example.com Address of the central Zabbix server or the proxy assigned to this host.
198.51.100.20 Actual source IP of the server or proxy that contacts the agent for passive checks.
server.example.com-psk A unique, non-secret identity for this host’s key.
  • Active checks. The agent connects to the server or proxy on TCP 10051, retrieves the list of checks and sends the results. TCP 10050 can stay closed on the Hestia host.
  • Passive checks. The server or proxy connects to the agent on TCP 10050. Limit incoming connections to the authorized source addresses.

Enable both modes if you need both active and passive templates. On an internet-facing host, active checks alone reduce the number of inbound ports you need. Replace the sample names and addresses throughout. If the host uses a Zabbix proxy, use that proxy’s address in the agent configuration and firewall rules.

Generate a pre-shared key

Generate a separate random 256-bit key for each monitored host. The file holds only the hexadecimal key value. The guard below preserves an existing key.

sudo bash <<'SH'
set -euo pipefail
PSK=/etc/zabbix/agent2.psk
if [ -e "$PSK" ] || [ -L "$PSK" ]; then
    echo 'PSK already exists. Leaving it in place.'
    exit 1
fi
umask 077
set -o noclobber
openssl rand -hex 32 > "$PSK"
chown root:zabbix "$PSK"
chmod 640 "$PSK"
SH
sudo stat -c '%U:%G %a %n' /etc/zabbix/agent2.psk
sudo -u zabbix test -r /etc/zabbix/agent2.psk && echo 'The agent can read the PSK'

The PSK identity can be public. Store the secret key value in a password manager or encrypted backup and keep it out of Git, cron entries and command arguments. To copy it once into the Zabbix HTTPS administration interface, display it from a trusted private session.

sudo cat /etc/zabbix/agent2.psk

Keep the output private. If the key is compromised, generate a replacement and update both the agent and the frontend in the same maintenance window.

Configure the agent

Back up the configuration supplied by the package before editing it.

sudo cp -a /etc/zabbix/zabbix_agent2.conf \
    "/etc/zabbix/zabbix_agent2.conf.bak.$(date +%Y%m%d-%H%M%S)"
sudoedit /etc/zabbix/zabbix_agent2.conf

Edit or uncomment the existing settings and check files loaded by Include= for duplicate definitions. Keep the package defaults for logs, sockets and plugins. To enable active and passive checks together, use the following settings.

Hostname=server.example.com
Server=198.51.100.20
ServerActive=monitor.example.com:10051
TLSConnect=psk
TLSAccept=psk
TLSPSKIdentity=server.example.com-psk
TLSPSKFile=/etc/zabbix/agent2.psk

TLSConnect controls outbound connections from the agent. TLSAccept controls inbound connections. Leave unencrypted out of the allowed modes to enforce TLS-PSK. For active checks only, comment out or remove every effective Server= directive, keeping ServerActive and the TLS settings. Without Server, Agent 2 leaves the passive listener closed. For passive checks only, omit ServerActive and keep Server and the TLS settings. The older agent’s StartAgents=0 setting does not apply to Agent 2.

Validate the configuration as the service user.

sudo -u zabbix /usr/sbin/zabbix_agent2 \
    -c /etc/zabbix/zabbix_agent2.conf -T

Configure the host in the Zabbix frontend

On the central Zabbix server, open Data collection > Hosts > Create host. If you are migrating an existing host, edit its existing entry.

  1. Set Host name to exactly the agent’s Hostname. The visible name can differ. When migrating an existing host, update its interface on the same host entry to keep its history.
  2. Select the appropriate group and, if applicable, the assigned proxy.
  3. For passive checks, add an Agent interface with the Hestia host’s reachable IP address or DNS name and port 10050. Active items alone need no interface unless another template requires one.
  4. Link Linux by Zabbix agent for passive checks or Linux by Zabbix agent active for active ones. Avoid linking both variants when they define duplicate items. Add Apache, Nginx or MariaDB templates only for services you run, and configure each template’s macros and credentials as documented.
  5. On the Encryption tab, select PSK under Connections to host for passive checks. For active checks, allow only PSK under Connections from host. You can set both directions to PSK even if you use only one.
  6. Enter the exact TLSPSKIdentity as the PSK identity (server.example.com-psk in the example). Paste the value from /etc/zabbix/agent2.psk into PSK. Save and enable the host.

The frontend labels describe the Zabbix server’s perspective. To host means the server contacts the agent. From host means the agent contacts the server. The host name, PSK identity and secret key each have their own field.

Configure the Hestia firewall and start the agent

For passive checks, inspect the existing rules and allow TCP 10050 only from the monitoring server or proxy. Replace the reserved example address below with the real source IP and run the commands on the Hestia host.

sudo /usr/local/hestia/bin/v-list-firewall
sudo /usr/local/hestia/bin/v-add-firewall-rule \
    ACCEPT 198.51.100.20/32 10050 TCP 'Zabbix agent TLS PSK'

Skip this inbound rule for active-only checks. If a broader rule already permits the same port, check its dependencies before narrowing or removing it. Active checks need outbound TCP 10051 from Hestia to the server or proxy. Any corresponding inbound rule belongs on the monitoring server or proxy. Also check the provider firewall and, for IPv6 or a VPN, the rules for the address family and interface the connection uses. Manage host rules through Hestia so they survive firewall regeneration.

sudo systemctl enable --now zabbix-agent2
sudo systemctl status zabbix-agent2 --no-pager
sudo journalctl -u zabbix-agent2 -n 50 --no-pager
sudo ss -lntp 'sport = :10050'

For passive checks, the agent should listen on port 10050. With active checks only, it should leave that port closed. If the package logs to a file, check LogFile as well as the systemd journal.

sudo grep -E '^(LogType|LogFile)=' /etc/zabbix/zabbix_agent2.conf
sudo tail -n 50 /var/log/zabbix/zabbix_agent2.log

Test the installation

First confirm that the agent can read a local item.

sudo -u zabbix /usr/sbin/zabbix_agent2 \
    -c /etc/zabbix/zabbix_agent2.conf -t agent.ping

The local check exercises only the agent. To test the network and TLS for passive checks, run zabbix_get from the authorized server or proxy, using a compatible version of the zabbix-get package. Give only the user running the test access to a protected copy of the same PSK. Pass the file path to the command to keep the key value out of its arguments.

zabbix_get -s server.example.com -p 10050 -k agent.ping \
    --tls-connect=psk \
    --tls-psk-identity='server.example.com-psk' \
    --tls-psk-file=/secure/path/agent2.psk

Expect 1. For active checks, allow time for the server or proxy to refresh its configuration cache and wait at least one collection interval. Then check the agent log and Monitoring > Latest data in the frontend. An active-only connection must be verified this way because zabbix_get tests passive checks.

If data is missing, use the symptom to narrow the search.

  • Timeout or connection refused. Check the direction of the connection, IP or DNS name, port, firewall and listener.
  • TLS error or unknown PSK. Compare the identity, the key value and the directions on the Encryption tab. Check the key file’s permissions.
  • host not found for active checks. Check Hostname, the host’s enabled status and the proxy assignment in the frontend.
  • System metrics arrive, but a service item is unsupported. Check its template, macros, local endpoint and the Zabbix process’s permissions. Let the local agent reach the Apache or Nginx HTTP status endpoint as the template requires, keeping it off the public internet.

See the official Debian 13 repository, Agent 2 configuration, PSK encryption and Hestia firewall documentation.

Diagnose false Apache and Nginx process alerts

Apache and Nginx can serve HTTP statistics while Agent 2 reports zero for their proc.num items. The HTTP checks and process counts use different mechanisms. Before changing a template, compare which processes root and the Zabbix user can see.

systemctl is-active apache2 nginx zabbix-agent2
sudo ps -eo pid,user,comm,args | grep -E '[a]pache2|[n]ginx' || true
sudo -u zabbix ps -eo pid,user,comm,args | grep -E '[a]pache2|[n]ginx' || true
findmnt -no OPTIONS /proc
systemctl show zabbix-agent2 -p User -p ProtectProc -p ProcSubset
sudo -u zabbix /usr/sbin/zabbix_agent2 -t 'proc.num[apache2]'
sudo -u zabbix /usr/sbin/zabbix_agent2 -t 'proc.num[nginx]'

If hidepid=invisible (equivalent to hidepid=2) is active, root sees the processes, the agent cannot see them and its tests return zero, the cause is the visibility restriction on /proc. Hestia can enable it to isolate users. Keep that protection for web accounts and use gid= to grant an exception to a dedicated group. The group can inspect processes beyond Apache and Nginx, so add only the trusted monitoring user.

Apply the change to the current mount

If /proc already uses a different gid=, stop and check who needs the existing access. Each procfs mount supports one exception group.

sudo bash <<'SH'
set -euo pipefail
OPTS=$(findmnt -no OPTIONS /proc)
case ",$OPTS," in
    *,hidepid=invisible,*|*,hidepid=2,*) ;;
    *) echo 'hidepid=2 is absent. Check the cause.'; exit 1 ;;
esac
getent group zabbix-proc >/dev/null || groupadd --system zabbix-proc
GID=$(getent group zabbix-proc | cut -d: -f3)
if [[ ",$OPTS," == *,gid=* && ",$OPTS," != *,gid="$GID",* ]]; then
    echo 'A different group already has access. Check before proceeding.'
    exit 1
fi
usermod -aG zabbix-proc zabbix
if [[ ",$OPTS," != *,gid="$GID",* ]]; then
    mount -o "remount,$OPTS,gid=$GID" /proc
fi
systemctl restart zabbix-agent2
findmnt -no OPTIONS /proc
runuser -u zabbix -- /usr/sbin/zabbix_agent2 -t 'proc.num[apache2]'
runuser -u zabbix -- /usr/sbin/zabbix_agent2 -t 'proc.num[nginx]'
SH

Counts should be greater than zero while the services are running. If they stay at zero, check the process names and the agent’s systemd restrictions. Avoid setting ProtectProc=default indiscriminately or running Zabbix as root.

Keep the change across reboots

Find every mechanism that can remount /proc, including any startup cron entry Hestia created.

getent group zabbix-proc
sudo grep -RnsE 'hidepid|[[:space:]]/proc[[:space:]]' \
  /etc/fstab /etc/systemd/system /etc/cron.d 2>/dev/null || true
sudo cp -a /etc/fstab "/etc/fstab.bak.$(date +%Y%m%d-%H%M%S)"
sudoedit /etc/fstab

If fstab already has a /proc entry, update it and preserve its other options. Otherwise, add an entry. Replace ACTUAL_GID with the numeric group ID reported by getent on this server. Group IDs can differ between hosts. This example retains the usual mount restrictions.

proc /proc proc nosuid,nodev,noexec,relatime,hidepid=2,gid=ACTUAL_GID 0 0

If /etc/cron.d/hestia-proc remounts /proc at boot with hidepid=2, make sure it also preserves the exception. Back up the file outside /etc/cron.d. Edit the existing command to retain the protection and include the same gid=ACTUAL_GID. A second competing cron job can undo the change.

# Only if the file exists and contains the Hestia remount described above.
sudo cp -a /etc/cron.d/hestia-proc "/root/hestia-proc.bak.$(date +%Y%m%d-%H%M%S)"
sudoedit /etc/cron.d/hestia-proc

If the standard cron entry runs mount -o remount,defaults,hidepid=2 /proc, the edited entry would look like this. Substitute the actual numeric group ID.

@reboot root sleep 5 && mount -o remount,nosuid,nodev,noexec,relatime,hidepid=2,gid=ACTUAL_GID /proc

Preserve required options from other mount or hardening rules, and ensure they all use compatible group settings. If Hestia has no such cron job and fstab is sufficient, skip the cron entry. Verify fstab and reload systemd.

sudo findmnt --verify --verbose
sudo systemctl daemon-reload
findmnt -no OPTIONS /proc

The remount has already applied the change, so verification can wait until the next scheduled reboot. Once cron and Zabbix have started, rerun findmnt and the agent checks. Also verify that an ordinary web account still cannot see other users’ processes. Repeat the checks after Hestia updates because its hardening scripts may recreate configuration files. HestiaCP server configuration and Linux procfs documentation

10.3 Audit performance after migration

Measure CPU, memory, I/O and PHP-FPM saturation over a representative period before changing more settings. These read-only checks capture the current state.

lscpu | grep -E 'Model name|CPU\(s\)|Thread|Core|Socket'
free -h
sudo swapon --show
uptime
sudo ps -eo pid,user,comm,rss,%cpu --sort=-rss | head -n 25
vmstat 1 5
lsblk -d -o NAME,SIZE,ROTA,MODEL
systemctl is-enabled fstrim.timer || true
sudo apache2ctl -M 2>/dev/null | grep -E 'mpm_|http2|proxy_fcgi' || true
sudo grep -HnE '^[[:space:]]*(pm[[:space:]]*=|pm\.max_children|pm\.max_requests|pm\.process_idle_timeout)' \
  /etc/php/*/fpm/pool.d/*.conf 2>/dev/null || true
for bin in /usr/sbin/php-fpm[0-9]*; do
    [ -x "$bin" ] || continue
    echo "--- $bin ---"
    sudo "$bin" -i 2>/dev/null | grep -E \
      '^(opcache.enable|opcache.memory_consumption|opcache.jit|opcache.jit_buffer_size|opcache.max_accelerated_files|opcache.validate_timestamps|opcache.revalidate_freq|realpath_cache_size) =>' || true
done
sudo journalctl -k --since '7 days ago' --no-pager \
  | grep -Ei 'out of memory|oom-killer|killed process' | tail -n 15 || true

If Valkey is installed, check its persistence, memory policy, latency and Transparent Huge Pages (THP) settings. If the instance uses access control lists or a password, CONFIG GET requires appropriate credentials. Keep credentials out of shared terminal output.

systemctl is-active valkey-server
sudo valkey-cli INFO memory
sudo valkey-cli INFO persistence
sudo valkey-cli CONFIG GET disable-thp maxmemory maxmemory-policy
sudo sysctl vm.overcommit_memory vm.swappiness
cat /sys/kernel/mm/transparent_hugepage/enabled
VPID=$(systemctl show -p MainPID --value valkey-server)
if [ "$VPID" -gt 0 ]; then
    sudo grep '^THP_enabled:' "/proc/$VPID/status" || true
fi

Check THP on the Valkey process as well as the system-wide setting. If the instance holds persistent queues, an eviction policy that discards jobs is unsuitable. Choose Valkey settings for the actual cache, queue and persistence requirements. Hestia itself does not require this tuning.

Interpret the measurements before making changes. With few CPU cores, too many PHP workers can saturate the CPU even when plenty of RAM is available. Verify mpm_event and proxy_fcgi before considering any changes. The Companion manages OPcache and JIT, so evaluate both under the real workload. Check that the SSD or RAID storage supports discard before enabling periodic TRIM. Adjust global swappiness, THP or the I/O scheduler only when measurements point to a problem. Limit framework-specific optimizations to the domains that use that framework.

10.4 Show system information at SSH login

A small dynamic message of the day (MOTD) can display basic system information at each SSH login. It reads local data, exposes no credentials and runs independently of systemd services. Check what is already configured.

ls -la /etc/update-motd.d/
cat /etc/motd

Add a script that reads the machine’s actual hostname.

sudo install -d /etc/update-motd.d
sudo tee /etc/update-motd.d/10-server-info >/dev/null <<'SH'
#!/bin/sh
printf '\n%s\n' "$(hostname -f 2>/dev/null || hostname)"
printf 'OS      : %s\n' "$(. /etc/os-release; printf '%s' "$PRETTY_NAME")"
printf 'Kernel  : %s\n' "$(uname -r)"
printf 'IPv4    : %s\n' "$(ip -o -4 addr show scope global | awk '{print $4}' | paste -sd ' ' -)"
printf 'IPv6    : %s\n' "$(ip -o -6 addr show scope global | awk '{print $4}' | paste -sd ' ' -)"
printf 'Uptime  : %s\n' "$(uptime -p)"
printf 'Load    : %s\n' "$(cut -d ' ' -f 1-3 /proc/loadavg)"
printf '\n'
SH
sudo chmod 755 /etc/update-motd.d/10-server-info
sudo sh -n /etc/update-motd.d/10-server-info
sudo /etc/update-motd.d/10-server-info

Check the result in a new SSH session. The server’s PAM and SSH settings control whether it appears. If an old static banner duplicates the output, identify which files are loaded and edit that banner separately. Preserve unrelated provider scripts. Shell customizations such as Oh My Bash are optional and background services should run independently of them.

11. Troubleshoot outbound connections (optional)

After a migration, an application may time out intermittently when contacting an API, webhook or external HTTPS service even while the sites on the server respond normally. Possible causes include DNS, IPv4 or IPv6 connectivity, routing, firewalls, packet size limits (MTU), TLS negotiation, a proxy or the remote service itself. For example, a bot calling the Telegram API might report cURL error 28. That code tells you the request timed out. You still need to locate the delay.

These checks use a public URL without credentials. Run them on the old and new servers against the same endpoint, as close together in time as possible. Use the account or container that runs the application. Exclude tokens, Authorization headers, cookies and signed URLs from logs you share.

11.1 Isolate DNS, routing and IP address family

HOST=api.telegram.org
URL="https://$HOST/"

echo '===== VERSIONS ====='
cat /etc/os-release
uname -r
curl --version
openssl version -a

echo '===== DNS RESOLUTION ====='
getent ahosts "$HOST"
dig +short A "$HOST"
dig +short AAAA "$HOST"
echo '===== ADDRESSES AND ROUTES ====='
ip -br addr
ip -4 route
ip -6 route

echo '===== DIRECT HTTPS TESTS ====='
for FAMILY in 4 6; do
    echo "===== IPv$FAMILY ====="
    for i in 1 2 3 4 5; do
        curl -"$FAMILY" --noproxy '*' -sS -o /dev/null \
            --connect-timeout 5 --max-time 15 \
            -w 'HTTP=%{http_code} IP=%{remote_ip} DNS=%{time_namelookup}s TCP=%{time_connect}s TLS=%{time_appconnect}s TTFB=%{time_starttransfer}s Total=%{time_total}s exit=%{exitcode}\n' \
            "$URL" || true
    done
done

Set HOST to the service you are investigating. For this direct test, --noproxy '*' bypasses proxies configured in the environment. If the application requires a proxy, compare the result with its normal route. Each time is cumulative from the start of the request. When both values are present, subtract TCP from TLS to estimate the time spent on the handshake. Fields for stages the request never reached may remain at zero.

Result What to check next
Could not resolve host or curl error 6 Check the resolver, DNS records and container configuration. If you use systemd-resolved, check resolvectl status.
Timeout before TCP connects Check the route, source IP, outbound firewall, provider’s network path and remote service availability.
TCP connects, but TLS stalls or takes a long time Check TLS versions, libraries, cipher suites, MTU, path MTU discovery (PMTUD) and any intermediate network devices.
TLS completes, but the HTTP response is slow Check the remote service, proxy, congestion and application timeouts.
IPv4 is stable, IPv6 is intermittent Investigate the IPv6 route. Consider an IPv4 preference as a workaround (section 2.5 of chapter 2).
HTTP 200, 302, 401, 403 or 429 The server returned an HTTP response. Check authentication, redirects, rate limits and application code to establish whether the actual API call succeeded.

Curl displays 000 when it receives no valid HTTP status code. An unanswered ping alone tells you little about HTTPS reachability.

To isolate DNS and repeatedly test the same endpoint, choose an address from the actual A or AAAA records. The --resolve option overrides name resolution for that request while retaining the HTTP host name, TLS Server Name Indication (SNI) and normal certificate verification.

HOST=api.telegram.org
IP4=$(dig +short A "$HOST" | awk '/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/ {print; exit}')
if [ -n "$IP4" ]; then
    ip -4 route get "$IP4"
    curl -4 --noproxy '*' -v --connect-timeout 5 --max-time 15 \
        --resolve "$HOST:443:$IP4" "https://$HOST/" -o /dev/null
fi
IP6=$(dig +short AAAA "$HOST" | awk '/:/ {print; exit}')
if [ -n "$IP6" ]; then
    ip -6 route get "$IP6"
    curl -6 --noproxy '*' -v --connect-timeout 5 --max-time 15 \
        --resolve "$HOST:443:[$IP6]" "https://$HOST/" -o /dev/null
fi

If DNS returns several frontend addresses, repeat the tests against more than one. These addresses can change, so avoid pinning them in /etc/hosts or your application as a permanent fix. If routing looks correct, test other dual-stack services to establish whether the IPv6 issue extends beyond this endpoint. For MTU investigations, use tracepath from the iputils-tracepath package or a targeted, authorized packet capture. Filtering can suppress traceroute or ICMP replies, making an unanswered probe inconclusive.

11.2 Compare TLS versions and cipher suites

If TCP connects but TLS fails or times out, hold the IP, hostname, address family and network path constant while comparing TLS settings. Keep certificate verification enabled, avoid -k and preserve global TLS requirements.

HOST=api.telegram.org
IP=$(dig +short A "$HOST" | awk '/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/ {print; exit}')
if [ -n "$IP" ]; then
    for TLS in 1.2 1.3; do
        echo "===== TLS $TLS ====="
        for i in 1 2 3; do
            curl -4 --noproxy '*' --http1.1 -sS -o /dev/null \
                --resolve "$HOST:443:$IP" \
                "--tlsv$TLS" --tls-max "$TLS" \
                --connect-timeout 5 --max-time 15 \
                -w 'HTTP=%{http_code} IP=%{remote_ip} TCP=%{time_connect}s TLS=%{time_appconnect}s Total=%{time_total}s exit=%{exitcode}\n' \
                "https://$HOST/" || true
        done
    done
fi

With an OpenSSL-based curl build, repeat the TLS 1.2 tests with --ciphers ECDHE-RSA-AES128-GCM-SHA256 or --ciphers ECDHE-RSA-AES256-GCM-SHA384. For TLS 1.3, use --tls13-ciphers TLS_AES_128_GCM_SHA256 or --tls13-ciphers TLS_AES_256_GCM_SHA384. These examples isolate a variable during diagnosis. Leave production cipher selection alone. The remote server must support the suite and curl’s TLS backend must recognize the option. ECDSA certificates may require different TLS 1.2 suites. Compare the versions of libcurl and the TLS backend in the application as well. PHP and the curl command may use different builds.

# Use the PHP version that runs the application.
php8.4 -r 'print_r(curl_version());'
php8.4 --ri curl

If only one combination of TLS version, cipher and IP fails, repeat the same test from another machine or network before attributing the failure to a suite the remote host rejects. An authorized VPN exit is another path you can test. A consistent difference between paths may point to routing or intermediate filtering. More evidence is needed to locate the cause. Avoid speculative changes to firewalls, MTU or the TLS configuration of every application.

11.3 Apply a workaround and report the issue

If the issue affects only IPv6 for a specific service, first try preferring IPv4 in that service’s HTTP client. Guzzle’s force_ip_resolve option and PHP cURL’s CURLOPT_IPRESOLVE let you scope the workaround to the affected client. Section 2.5 covers the system-wide /etc/gai.conf alternative. Chapter 2

Set suitable connection and request timeouts. Use retries with backoff only for idempotent operations or requests protected against duplication. When a write request times out, the remote service may already have processed it.

When reporting the problem to your provider or the API maintainer, include the date, time and time zone, operating system, curl and OpenSSL versions, remote hostname and IP, address family, TLS version and cipher you tested. Include the outcomes and timings from repeated requests, how they compare across network paths and which checks passed. Remove credentials, private URLs and application data before sharing. Distinguish observations from possible causes. The Telegram example makes no assumption about which service or provider is responsible. curl manual, curl TLS cipher suites and gai.conf(5)

References

These procedures and scripts are operational examples for Debian 13 and HestiaCP, reconstructed from the original configuration and adapted for a fresh installation. Verify version- and environment-specific parameters on the servers you will use. The shell blocks were checked separately for syntax. The guide was not tested in a fresh deployment.