Introduction:
When managing a WHM (Web Host Manager) server, ensuring the safety of your DNS records is crucial for disaster recovery and smooth server operation. Backing up DNS records allows you to restore configurations quickly in case of accidental deletions, migrations, or server failures.
Method 1: Backup DNS Zones Using WHM Interface
WHM provides an easy-to-use interface to enable DNS zone backups as part of its backup configuration.
Steps:
- Log in to WHM as root.
- Navigate to “Backup” → “Backup Configuration“.
- Scroll down to the section labeled “Additional Backup Content”.
- Ensure that “Enable DNS Zone Backups” is checked.
- Click “Save Configuration”.
- To generate a manual backup, go to “Backup” → “Backup Now” and initiate the process.
This method ensures that your DNS zones are included in your regular backup schedule.
Method 2: Manually Backup DNS Zones via SSH
If you prefer manual backups, we can directly copy DNS zone files from the WHM server.
Steps:
- Connect to your server via SSH as root.
- Run the following command to create a compressed backup of all DNS records:
tar -czvf /root/dns_zones_backup.tar.gz /var/named/
- This will create a file named
dns_zones_backup.tar.gz
containing all DNS zone files. - To download the backup to your local machine, use
scp
:
scp root@your-server-ip:/root/dns_zones_backup.tar.gz /your/local/path/
Method 3: Backup a Specific Domain’s DNS Records
If you need to back up only a particular domain’s DNS records, follow these steps:
Steps:
- Locate the DNS zone file in
/var/named/
. - Run the following command to copy the specific domain’s file:
cp /var/named/example.com.db /root/example.com.db.backup - Transfer the backup file to your local system using
scp
or FTP.
Restoring DNS Records
In case of a failure or accidental deletion, we can restore DNS records using the following steps:
Restore Full Backup:
tar -xzvf /root/dns_zones_backup.tar.gz -C /
Restore a Specific Domain:
cp /root/example.com.db.backup /var/named/example.com.db
Restart the DNS Service:
systemctl restart named
Conclusion
Backing up DNS records in WHM is a critical maintenance task that ensures websites and services remain accessible in case of issues. By utilizing WHM’s built-in backup system, manual file copies, or the WHM API, we can protect our server from DNS-related disasters.