Saturday, December 28, 2024
Google search engine
HomeGuest BlogsHow to Configure Cpanel Backups to S3 Object Store

How to Configure Cpanel Backups to S3 Object Store

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 /backu

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:

$ sudo vim /etc/fstab
dev/mapper/vg0-backups /backup xfs defaults 0 0

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:

Other AWS articles available in our blog are:

RELATED ARTICLES

Most Popular

Recent Comments