Data backup is the most important part of running a business, especially in the Cloud space. With Cpanel, you have the option to backup your website data and databases locally, or to a cloud storage like Amazon S3.  In this guide, we will configure a Cpanel automated backup policy – locally and to S3 Object storage.

How to Configure a Backup Policy in Cpanel

To configure Cpanel policy, login to WHM and search for “Backup” the open linkBackup Configuration.

configure cpanel backup s3 01

By default Cpanel Backup is disabled, enable it by clicking the “Disable” button under Backup Status:

configure cpanel backup s3 02

Under Backup Type, choose “Compressed

configure cpanel backup s3 03

When you select incremental backups, the system will not change or alter the state of your existing non-incremental backup destinations. Rsync transport is used for incremental backups.

Set minimum free Disk Space check before the system performs the backups. I recommend setting `10%`

configure cpanel backup s3 04

Under Scheduling and Retention, set backup times that fit your setup

configure cpanel backup s3 05

You can also choose a weekly and monthly backups with a retention policy

configure cpanel backup s3 06

Configure Backup Directory

My Cpanel server has a dedicated disk for Backups /dev/xvdf:

# lsblk
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
xvda    202:0    0  160G  0 disk
└─xvda1 202:1    0  160G  0 part /
xvdf    202:80   0  100G  0 disk

I’ll partition and mount this disk to /backup directory.

sudo parted -s -a optimal -- /dev/xvdf mklabel gpt
sudo parted -s -a optimal -- /dev/xvdf mkpart primary 0% 100%
sudo parted -s -- /dev/xvdf align-check optimal 1

Install LVM Tools

sudo yum -y install lvm2

Configure LVM and mount the partition to /backup

sudo pvcreate /dev/xvdf1
sudo vgcreate vg0 /dev/xvdf1
sudo lvcreate -n backups -l+100%FREE vg0
sudo mkfs.xfs /dev/mapper/vg0-backups

Confirm configurations

# lsblk -f /dev/xvdf
NAME            FSTYPE      LABEL UUID                                   MOUNTPOINT
xvdf
└─xvdf1         LVM2_member       zaDr75-WB07-dVsB-4Mtk-CUS9-fcq1-9KXQoO
  └─vg0-backups xfs               d0fb587e-3bd4-4084-81e7-5c2b209635e7

Create the /backupdirectory if doesn’t exist:

[ -d /backup ] || sudo mkdir /backup

Set mount on boot for the Logical Volume:

echo "/dev/mapper/vg0-backups /backup xfs defaults 0 0" | sudo tee -a /etc/fstab

Mount the partition:

$ sudo mount -a
$ df -h | grep backups
/dev/mapper/vg0-backups  100G   33M  100G   1% /backup

Confirm Default Backup Directory and save your Configurations

configure cpanel backup s3 set backup directory

Create S3 Bucket for Cpanel

Login to your AWS dashboard and navigate to S3 > Create bucket

configure cpanel backup s3 create bucket

Give the bucket a name and configure options and permissions then click “Create bucket“.

Go back to WHM Backup Configuration section, then click on Additional Destinations

configure cpanel backup s3 07

Choose Amazon S3 and hit Create new destination. On the next page, provide Destination Name:

configure cpanel backup s3 08

Provide system Backups folder, AWS S3 bucket name, Access Key ID and Secret Access Key:

configure cpanel backup s3 09

When done, Save Destination. Good work!. Your Cpanel backup policy for both locally and to S3 Object Store has been configured. You can also read:

How to Install PHP Composer on Cpanel

How to add PHPZIP Archive in cPanel

Configure Cpanel Firewalld on CentOS 7

Other AWS articles available in our blog are:

How to extend EBS boot disk on AWS without an instance reboot

Create AWS S3 Upload and List Objects Policy without Delete Action

How to Configure Cpanel Backups to S3 Object Store

How to Install and Use AWS CLI on Linux – Ubuntu / Debian / CentOS

How to Reset RDS Master User Password on AWS

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!


As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.

LEAVE A REPLY

Please enter your comment!
Please enter your name here