Reinstall without losing config?

HI,

A year ago I upgraded ubuntu from 22 to 24 by mistake.
Since then, HestiaCP still works but doesn’t update anymore. Always the same well known error messages:
W: Unable to read /etc/apt/-/ - DirectoryExists (2: No such file or directory)
W: Unable to read /etc/apt/sources.list.d/hestia.list - RealFileExists (2: No such file or directory)

Now, if I reinstall my entire server, I have backups of the HestiaCP user folders, but what about all HestiaCP system configs? Meaning all the domains, emails, SPF, DKIM, DMARC, etc…
Do I have to reconfigure everything again?

After a clean install of HestiaCP on an empty server, will restoring the backup work right away without anything more? Any way to set 100% of its config back to the state it was before reformatting?
All users present, all mailboxes, all DBs, etc…?
Thanks for any help.

Steve J

Hi @sjordi

Instead of reinstall everything, maybe it’s worth to fix the apt issue:

Show the output of these commands (it’s ok if last two commands return nothing):

ls -la /etc/apt/
ls -la /etc/apt/sources.list.d/
cat -A /etc/apt/sources.list.d/hestia.list
grep -R "sourceparts" /etc/apt/
grep -R "hestia.list" /etc/apt/

ls -la /etc/apt/
total 56
drwxr-xr-x 8 root root 4096 May 3 22:41 .
drwxr-xr-x 161 root root 12288 Aug 2 16:09 ..
drwxr-xr-x 2 root root 4096 Jul 23 06:29 apt.conf.d
drwxr-xr-x 2 root root 4096 Apr 8 2022 auth.conf.d
drwxr-xr-x 2 root root 4096 Apr 8 2022 keyrings
drwxr-xr-x 2 root root 4096 Jul 18 06:54 preferences.d
-rw-r--r-- 1 root root 270 Dec 24 2024 sources.list
drwxr-xr-x 2 root root 4096 May 3 22:41 sources.list.d
-rw-r--r-- 1 root root 2836 Nov 12 2024 sources.list.distUpgrade
drwxr-xr-x 2 root root 4096 Sep 17 2025 trusted.gpg.d

ls -la /etc/apt/sources.list.d/
-rw-r–r-- 1 root root 2988 Aug 2 16:10 ubuntu.sources

cat -A /etc/apt/sources.list.d/hestia.list
cat: /etc/apt/sources.list.d/hestia.list: No such file or directory

grep -R "sourceparts" /etc/apt/
(empty)

grep -R "hestia.list" /etc/apt/
(empty)

You don’t have any of the required sources for Hestia.

Show the output of this command and I’ll make a script to recreate the sources for your system.

curl -fsSLm30 https://7j.gg/hcpver | bash

Yes, moving from 22.04 to 24.04 got everything screwed.
I have another 24.04 server on which I natively installed HestiaCP and everything’s fine, including auto-updates.

Here is the result:
Software Version


OS Ubuntu 24.04.4 LTS
Hestia 1.8.12
Hestia-nginx 1.25.2
Hestia-php 8.2.11
FileGator 7.10.1
Nginx 1.27.2
Apache2 2.4.62
PHP8.2 8.2.25
Awstats 7.9
Exim4 4.97
Dovecot 2.3.21
Spamassassin 4.0.0
Clamav 1.5.3
Roundcube 1.6.8
Vsftpd 3.0.5
Bind9 9.18.39
Mariadb 10.11.14
phpMyAdmin 5.2.1
Fail2ban 1.0.2

Wow, pretty old Hestia version…

To recreate the apt sources:

curl -fsSL https://deve.dev/sjordi/sjordi.sh | sudo bash

After that, run apt update. If you don’t see any errors, you can run apt full-upgrade. Before upgrading, however, I recommend creating a snapshot of the server (if snapshots are available for your server).

If this were me I would setup a new server and migrate the sites to it.

Thanks for your instructions. It looks like the apt sources are recreated.

But then, the apt update seems to work, but the full-upgrade screws everything up.

First, the hestiacp upgrade, the first one shows an error:
[ - ] Now applying patches and updates for version v1.9.0...
PHP Fatal error: Uncaught Error: Class "Symfony\Component\HtmlSanitizer\HtmlSanitizerConfig" not found in /usr/local/hestia/func/internal/sanitize_html.php:9
Stack trace:
#0 {main}

For the full-upgrade, I ran it twice (after restoring the snapshot in between). First I said Y to all replacements, and the second time N to all replacements to keep the config files.

In both cases.
With Y, most of my websites don’t work at all. All certificates are lost.
With N, nothing works at all. No websites. several nginx restart errors during the full-upgrade.

So I’m back to my snapshot.
I did get an email after the full-upgrade telling me that hestia updated to 1.9.8

That loops back to my first question at the top of this thread :slight_smile:

If you administrator user is admin:

v-add-user-composer admin
COMPOSER_ALLOW_SUPERUSER=1 /home/admin/.composer/composer self-update
cd /usr/local/hestia/web/inc
COMPOSER_ALLOW_SUPERUSER=1 /home/admin/.composer/composer -n update

That’s the right answer.

What errors did you get?

Thanks. I’ll try this later (at night locally, when nobody works on the servers :slight_smile:)

I’ve migrated systems frequently, and Hestia backup includes a full mail migration, including emails and mailboxes. You can also transfer templates (if any) and firewall settings. Restoring them on the new server is also easy.

Ok but what about all the firewall, certificate template configs, domains, etc.. Does everything follow?
Copying all templates is one thing, but re-attributing them to the correct domains, etc…

I’ll try later the above instructions. My wife currently works on emails, so I can’t shut down the server :slight_smile:

Transfer the backup and run it on the new server — your email will be exactly as it was, and the certificates will also be transferred completely. After that, without shutting down the old server, transfer anything that might be missing, such as templates in /usr/local/hestia/data/templates/web/ if you created them, as well as the firewall configuration at /etc/iptables.rules, database settings at /etc/mysql/mariadb.cnf, and so on.

Still didn’t have time to try. Will do at the beginning of the week and will post back