Script: Import multiple DirectAdmin backup files and restore them at once in HestiaCP

Hello all,

With this script, you can import multiple DirectAdmin backups and restore them all at once in HestiaCP. The script will process each DirectAdmin backup file one by one.

You can download and run the script using the commands below. If the ‘v-import-directadmin’ script is not already present in your installation, the script will automatically download it for you.

wget -O import_da.sh https://gist.githubusercontent.com/ricardo777/7a77376f1da4766f9de6ffc49878e875/raw/1ffa8735e8574c2e674796ed3e33b71109ed9675/import_da.sh
chmod +x import_da.sh
./import_da.sh

Configuration Options:

Before running the script, ensure you have the correct paths and parameters set within the script:

  • Backup Directory: BACKUP_DIR="/root/daimport/backups"
  • Log File: LOG_FILE="/root/daimport/da-import-log.txt"

These settings should already be in the script.

For the import script (v-import-directadmin), you can set the following parameters within the script if necessary:

  • debug=1 (Enable debugging)
  • hestia_package=default (Specify Hestia package)
  • letsencrypt_enable=1 (Enable Let’s Encrypt)
  • addusertext='IMPORTED' (Custom user text, will be added in ‘Contact Name’ in HestiaCP user account)
  • tmp_dir='tmp_dir_da_backup' (Temporary directory for backups)
3 Likes

Hi, anyone have tried this script? How it did go? Good?

You can use DirectAdmin to create a backup, download it, test it, and maybe get results!

I tested the script througly, on multiple direct admin servers. But it is always important to make good backups.

The topic script is only a script that pulls the import script from the Hestiacp GitHub when you not have it already and has some coding to allow importing multiple files at once. Which the Hestiacp does not support natively.

When you run into issues, please let me know so I can fix them.

1 Like

Hi, The script works perfectly for restoring the public_html folder and the database. It also restores the email accounts with the correct passwords. However, when I access Roundcube afterwards, I see the email count but no messages are visible. I have checked the file permissions and ownership, and they are correct. I also tried rebuilding the dovecot.index file but was unable to resolve the issue.

Do you have mail compression enabled on the directadmin server? Specifically this

You can try decompress it and restore a new backup to test it.

3 Likes

Perfect!

On Directadmin:

da build set mail_compress no
da build dovecot_conf

/usr/local/directadmin/scripts/dovecot_compress.sh decompress_all

After made backup again, now it work.

Many thanks.

2 Likes

@Webmart, keep in mind that you can also configure Dovecot in Hestia to compress and decompress Maildir files, so you don’t need to decompress them in DirectAdmin, back them up, and then restore them in Hestia.

Example using zstd as the compression library:

Instal the required packages:

apt install zstd libzstd1 libzstd-dev

Edit file /etc/dovecot/conf.d/10-mail.conf and add this line to the end:

mail_plugins = zlib

Edit /etc/dovecot/conf.d/90-plugin.conf and add this inside the plugin directive:

  zlib_save = zstd
  zlib_save_level = 6

In context:

##
## Plugin settings
##

# All wanted plugins must be listed in mail_plugins setting before any of the
# settings take effect. See <doc/wiki/Plugins.txt> for list of plugins and
# their configuration. Note that %variable expansion is done for all values.

plugin {
  #setting_name = value
  zlib_save = zstd
  zlib_save_level = 6
}

Restart dovecot and it should work:

systemctl restart dovecot

Note: Keep in mind that you must use the same compression library used in DirectAdmin. If you are using gz in DA, configure zlib_save = gz, the same for bz2 or lz4.

1 Like