HEX
Server: nginx/1.18.0
System: Linux mail.dakarash.co.id 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64
User: www-data (33)
PHP: 8.1.2-1ubuntu2.23
Disabled: NONE
Upload Files
File: //usr/local/bin/mail-restore.sh
#!/bin/bash
# Restore konfigurasi mail server dari arsip backup

set -e
LATEST=$(ls -t /root/mail_backup_*.tar.gz 2>/dev/null | head -n1)
if [ -z "$LATEST" ]; then
  echo "Tidak ada file backup di /root/mail_backup_*.tar.gz"
  exit 1
fi

echo "Menggunakan backup: $LATEST"

TMP="/tmp/restore_mail_$$"
mkdir -p "$TMP"
tar -C "$TMP" -xzf "$LATEST"

cp -a "$TMP"/mail_backup_*/postfix/* /etc/postfix/ 2>/dev/null || true
cp -a "$TMP"/mail_backup_*/dovecot/* /etc/dovecot/ 2>/dev/null || true

postfix check || true
systemctl restart dovecot
systemctl restart postfix

echo "Restore selesai."
echo "Validasi listener:"
ss -ltnp | egrep ':25|:465|:587' || true