πŸ› οΈ Adjusting the Default Region in S3-Related Perl Module for Backup Validation

Overview

Some S3-compatible storage providers use custom regions that are not recognized by AWS’s default region list. This can lead to validation errors when configuring a remote backup destination in WHM. This guide walks you through how to manually adjust the default region in the Perl module used by cPanel to work around this issue.


βœ… Prerequisites

  • Root access to the server
  • Familiarity with Linux CLI
  • Basic knowledge of Perl modules and file editing
  • A text editor like vi or nano

🧩 Step-by-Step Instructions

1. Backup the Original S3.pm File

Always create a backup before making any changes:

mkdir -p /root/cptechs/95191212/
cp -a /usr/local/cpanel/3rdparty/perl/536/cpanel-lib/Amazon/S3.pm /root/cptechs/95191212/

2. Edit the S3.pm File

Open the module file in your preferred text editor:

vi /usr/local/cpanel/3rdparty/perl/536/cpanel-lib/Amazon/S3.pm

Find and replace the line containing:

'gra', 's3'

with:

'us-east-1', 's3'

This tells the module to use a default AWS-compatible region (us-east-1) instead of an unknown or unsupported region like gra.

Save and exit:

  • Press Esc
  • Type :wq
  • Hit Enter

3. Verify the Changes

Compare the original and modified files:

diff /usr/local/cpanel/3rdparty/perl/536/cpanel-lib/Amazon/S3.pm /root/cptechs/95191212/S3.pm

You should see:

141c141
<     'gra', 's3'
---
>     'us-east-1', 's3'

4. Validate the Backup Destination

Use WHM’s API to validate your S3-compatible backup destination:

whmapi1 backup_destination_validate id='lou4RGIkd6rUgyVuLVgXf7qp' disableonfail='1'

Expected output:

data:
  id: lou4RGIkd6rUgyVuLVgXf7qp
metadata:
  command: backup_destination_validate
  reason: OK
  result: 1
  version: 1

5. Confirm Backup Functionality

Run a test backup to verify everything is working as expected. If successful, the destination is now usable with your custom S3-compatible storage provider.


🧯 Rollback (If Needed)

If something goes wrong, restore the original S3.pm file:

cp -a /root/cptechs/95191212/S3.pm /usr/local/cpanel/3rdparty/perl/536/cpanel-lib/Amazon/S3.pm

πŸ“Œ Conclusion

This workaround helps bypass region compatibility issues for S3-compatible storage by modifying the default region in the Perl module used by cPanel. If the issue persists, consult your provider’s documentation for the correct S3 endpoint and required region values.

Scroll to Top