Why Host Backup is a Necessity?
Imagine you have spent hours working on your site content and suddenly, due to a human error, malware attack, or server failure, everything is lost. This is where host backup comes to your rescue. Regular backup not only protects your data but also increases restore speed during a crisis. In this article, we will step-by-step review the backup and restore process from common control panels like cPanel and DirectAdmin.
Types of Host Backup: Full vs. Partial
Before starting, you should know that backups are divided into two main categories:
- Full Backup: Includes all files, databases, email settings, DNS, and logs. This type of backup usually has a large size and is essential for a complete site restore.
- Partial Backup: Includes only specific parts such as public_html files or a particular database. This method is suitable for quick and low-volume storage.
It is recommended to perform a full backup at least once a week and a partial backup of dynamic content (such as the database) daily.
Backup from cPanel Control Panel
Steps for Full Backup
- Log into the cPanel control panel (usually via
yourdomain.com/cpanel). - Go to the Backup or Backup Wizard section.
- Select the Full Backup option.
- In the Backup Destination section, select the Home Directory option so the backup file is saved in the main folder.
- Click on Generate Backup. The process may take a few minutes.
- After completion, the file with the
.tar.gzformat will be located in the path/home/username/.
Downloading Local Backup
To download the backup to your system:
- Through File Manager in cPanel, go to the main folder and select the backup file.
- Click on the Download option. If the file size is large (over 500 MB), it is better to use SSH or FTP.
Example SSH command for download:
scp user@yourdomain.com:/home/username/backup-*.tar.gz /local/path/
Partial Backup (Database and Files)
For backing up only the database:
- Go to the phpMyAdmin section.
- Select the desired database.
- Click on Export and choose the SQL format.
- Download the file.
For backing up files:
- From File Manager, compress the
public_htmlfolder (right-click and select Compress). - Download the resulting ZIP or tar.gz file.
Backup from DirectAdmin Control Panel
Steps for Full Backup
- Log into DirectAdmin (usually via
yourdomain.com:2222). - Go to the Admin Tools or User Level section and select the Backup/Transfer option.
- In the Create Backup section, enable the following options:
- Full Backup
- Include Emails (if you have emails)
- Include Databases
- Click on Create Backup. The file with the
.tar.gzformat will be saved in the path/home/username/backups/.
Downloading Local Version
To download, use DirectAdmin's internal File Manager or FTP. If using FTP:
ftp yourdomain.com
cd /home/username/backups/
get backup-*.tar.gz
quit
Partial Backup in DirectAdmin
For backing up only the database:
- Go to the MySQL Management section.
- Click on the desired database and select the Export option.
- Save the SQL file.
For backing up files:
- From File Manager, compress the
domains/yourdomain.com/public_htmlfolder.
Secure Restore of Host Backup
Restoring Full Backup in cPanel
- Go to the Backup section in cPanel.
- Select the Restore a Full Backup option.
- Upload the backup file (
.tar.gzformat). - Wait for the process to complete. This may take 5 to 30 minutes depending on the file size.
Important Note: Before restoring, take another backup of your current files to avoid data loss in case of issues.
Restoring Partial Backup
For restoring the database:
- Log into phpMyAdmin.
- Select the destination database (if it does not exist, create it first).
- Click on Import and select the SQL file.
- Click on Go.
For restoring files:
- Extract the ZIP or tar.gz file on your system.
- From File Manager, upload the files to the
public_htmlfolder.
Common Mistakes in Host Backup and How to Avoid Them
Mistake One: Incomplete Backup Due to Internet Disconnection
When downloading a full backup, if the internet disconnects, the file remains incomplete and unusable. To avoid this:
- Use tools like rsync or wget with resume capability.
- Example wget command with resume capability:
wget -c http://yourdomain.com/backup.tar.gz
Mistake Two: Restoring on the Wrong Host
Many users restore a backup on another host and encounter errors. Always ensure before restoring that:
- The domain and DNS settings are correctly configured.
- The PHP and MySQL versions are compatible with the previous version.
Mistake Three: Not Checking Backup Integrity
After downloading, always test the backup file. For example, with the following command in Linux:
tar -tzf backup.tar.gz | head -20
This command shows the first 20 lines of the file contents and ensures its integrity.
Security Tips for Host Backup
- Backup Encryption: If you store the backup in the cloud, be sure to compress it with a strong password. In Linux, you can use
gpg:
gpg -c backup.tar.gz
- Off-Server Storage: Store the backup in cloud services like Google Drive or Dropbox. For this, use automated scripts like
rclone. - Regular Scheduling: Use Cron Job in cPanel or DirectAdmin for automatic backup. For example, a daily cron job for database backup:
0 3 * * * mysqldump -u username -p'password' dbname > /home/username/backups/db_$(date +\%Y\%m\%d).sql
Summary
Host backup is a critical process for any website. By following the steps above, you can easily back up your data, save a local copy, and perform a secure restore when needed. Remember that regular backup and off-server storage are the best ways to protect your information. If you are looking for more professional solutions, ServerNet's automated backup services can be a suitable option. But the most important point is to take a backup of your site today!