Skip to content

jeff-of/wrapper-for-pkgacct

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Wrapper script for WHM/cPanel's pkgacct

The backup.sh script is intended to work as a simple backup solution for cPanel accounts residing on a WHM server. It enables you to run backups from your local machine and "pull" them from your WHM web server, eliminating the need to open ports on your firewall. It also handles scheduling of daily, weekly, monthly, and yearly backups as well as a specified retention period for them. It then has the option to encrypt the backups and upload them to a specified offsite target.

Prerequisites

This script is a wrapper. It does not contain cPanel proprietary code and requires an existing cPanel/WHM environment to function.

  • cPanel/WHM License: A valid, active cPanel license is required on the host machine.
  • Root/Sudo Access: Necessary to execute /scripts/pkgacct.

Dependencies

On local machine running backup.sh

  • rsync
  • ssh
  • openssl (if encryption is enabled)
  • mail (email needs to be set up and working with a SMTP server if you want email alerts)

On backup source server

  • A WHM/cPanel installation with a valid license and the pkgacct script

On the offsite server (if used)

  • rsync
  • ssh

Installation and Usage

Clone the repository

git clone https://github.com/jeff-of/whmbackups

Make the script executable

chmod u+x backup.sh restore.sh

Edit the configuration file

nano config

If you have multiple different servers that need backups, you can copy the config file and set the variables to suit each server and accounts.

Example:

./backup.sh config-server1

./backup.sh config-server2

Usage

./backup.sh config

./restore.sh config /path/to/backup/file

The configuration file contains all the settings you need to tailor this script to your environment. Please review them carefully. Note that you will need root ssh access on your WHM server for this to work.

If you want to use backup encryption, generate a secure random encryption key and store it as the only thing in a text file. Make sure the file is in a secure place and accessible to the scripts.

Please do NOT include the encryption key file in the directory that you are storing your backups in! This will cause your key to be uploaded to the offsite server.

Schedule

This script is designed to to placed in your crontab and run once per day. Set the schedule in the config file with the daily. weekly, monthly, and yearly variables to specify what days you want the backups to actually run. If the script runs on a day it is not scheduled, it will write to the syslog that it was not scheduled that day and exit.

There is also a setting labeled one_off. If one_off is set to 1, a single backup will run regardless of the other schedule settings. This is meant to be used if you need an immediate backup. It will be stored at the root of your specified backup directory.

The restore script

The restore.sh script is intended to simplify restoring a backup. It simply unencrypts the backup file, then uploads it to the root home directory on the WHM server. Once the file uploads, you will still need to navigate to "Transfers > Transfer or Restore a cPanel Account" on your WHM server. Then select your uploaded tar.gz file from that interface.

License & Legal

This project is licensed under the MIT License. See the LICENSE file for details.

Disclaimer

This script is an independent tool and is not developed, endorsed, or supported by cPanel, L.L.C.

cPanel and WHM are registered trademarks of cPanel, L.L.C.

This script merely interacts with the pkgacct utility via its standard command-line interface. It does not redistribute or modify any cPanel proprietary binaries or source code.

Use at your own risk. Always test backup scripts in a non-production environment before deployment.

About

A script that enables you to pull, schedule, and encrypt account backups from a WHM/cPanel web server.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages