Get Started

Follow our installation guide to set-up and configure WHM Backup Solutions script.

Installation

Run Backup

  • 1. Download the latest version from https://whmbackup.solutions/download/
  • 2. Extract the files.
  • 3. Rename config.php.new to config.php.
  • 4. Open config.php in a text editor and enter your configuration details as documentated below.
  • 5. Upload all files to your server, in a location outside of your public web directory e.g. /home/user/whmbackupsolutions/.
  • 6. Login to your cPanel account, click Cron Jobs and create 2 cron jobs as described below.
    (While setting up the script for the first time it may be advisable to set the cron email within cPanel to your email address so you can confirm the script is running as expected.)
    • 6.1. Generate Backup List
      This cronjob should run as frequent as you want backups taking e.g. once a day/week/month etc. The command line should look similar to the code below. Ensuring the directory path is correct as per your installation.
                    php -q /home/user/whmbackupsolutions/whmbackup.php generate
                  
      (Please note if you have register_argv_argc disabled on your server this will not work. A work around is available under the troubleshooting steps).
    • 6.2. Run Account Backup
      This cronjob should run every 5, 10 or 15 minutes. We recommend setting this to every 5 minutes but if there are accounts larger than 2GB then the time between runs should be increased to reduce server load.
                    php -q /home/user/whmbackupsolutions/whmbackup.php
                  
  • 7. Wait until your cron jobs have run then check the logs in /logs/ for any errors. Then tweak your configuration as required.

Run FTP Retention Script

While this script works independently of the backup script the config file backup destination and max_backups_per_account settings must be filled in. I recommend using the steps above before proceeding with the steps below.

  • 8. Login to your cPanel account, click Cron Jobs and create a cron job as described below.
    (While setting up the script for the first time it may be advisable to set the cron email within cPanel to your email address so you can confirm the script is running as expected.)
    • 8.1. Run FTP Retention Script
      This script should be run after your backup script has been run, this will ensure you only store additional backups for a short period of time. However, the timing may require tuning based on how your web host has configured your server.
                    php -q /home/user/whmbackupsolutions/ftp_retention.php
                  

Configuration

Configuring the script is simple, just open config.php and follow our configuration guide to get you on your way in only a matter of minutes.

Options Value Example Value
$config['date_format'] The date format is shown in the logs, this format can be altered to suit localised preferences. For the full list of possible values see https://secure.php.net/manual/en/function.date.php. F j, Y, g:i:s a
$config['timezone'] To ensure the log dates and times line up with where you are, you can set the timezone your in. Possible values can be found https://secure.php.net/manual/en/timezones.php. Europe/London
$config['obfuscate_config'] To provide an additional layer of security albeit minor, you can obfuscate config.php the next time a backup list is generated. To do this just set the variable to true and your config.php contents will then be obfuscated and moved to secure-config.php and config.php will be deleted.
NOTE: This is not encryption! As the details of the config do need to be accessed by the script, your config will NOT be one way encrypted by setting this variable to true. This merely provides a basic obfuscation technique.
false
$config['check_version'] To ensure you are running the latest version of this script every time you generate a new backup you can enable checks back to https://whmbackup.solutions/check_version/.
There are 3 levels of update notifications you can set the configuration variable to.
0 - Disable Checking For Updates.
1 - Notify of Major Update.
2 - Notify of Major & Minor Updates.
2
$config['whm_hostname'] This is the hostname or ip address of the cPanel server your reseller is hosted on. mydomain.com
$config['whm_port'] The cPanel login port value. Typically this is 2086 for Non-SSL and 2087 for SSL connections. 2087
$config['whm_username'] This is your username used to login to your WHM. mydomain
$config['whm_auth'] To authenticate into your account this value can be set to either password or hash. The password or hash should then be entered into $config['whm_auth_key'];
password - Is the password used to login to your WHM.
hash - This is using the hash generated within WHM (Remote Access Key or API Token)
hash
$config['whm_auth_key'] This is the value of the password or hash to login with. myauthtoken
$config['type_of_backup'] The values of this setting can be numbers 1 to 6 as listed below.
1 = Backup All Accounts
2 = Backup Accounts Based On Account Username
3 = Backup Accounts Based On Hosting Package
4 = Backup Accounts Based On Primary Account Domain
5 = Backup Accounts Based On Account Owner
6 = Backup Accounts Based On IP
1
$config['backup_criteria'] Based on the type_of_backup setting above this should be set to the username/package/domain/owner/ip you want backing up. To seperate multiple criteria use commas.
E.g. user1,user2,user3
E.g. package1,package2,package3
NOTE: This will be ignored if $config['type_of_backup'] is set to 1
$config['backup_exclusions'] You can exclude accounts from being backed up by entering their usernames in this field.
$config['backup_email'] Specifying an email address in this field will cause a cPanel generated email for each account to be sent, the backup log generated by this script will also be sent to the email address specified. If this is left blank, email reports are disabled. me@mydomain.com
$config['backup_destination'] Possible values are homedir, ftp, passiveftp or scp.
homedir - Will cause a backup to be placed in the users home directory.
ftp - Will cause a backup to be sent to a remote FTP server.
passiveftp - Will cause a backup to be sent to a remote FTP server.
scp - Will cause a back to be sent to SSH or SFTP storage.
ftp
$config['backup_server'] The hostname/ip address of your remote FTP or SCP storage.
NOTE: This field is only required when $config['backup_destination'] is set to ftp, passiveftp or scp.
ftp.myftpserver.com
$config['backup_port'] The port to access your remote FTP or SCP storage.
e.g. Default FTP port is 21.
e.g. Default SSH port is 22.
NOTE: This field is only required when $config['backup_destination'] is set to ftp, passiveftp or scp.
21
$config['backup_user'] The username to access the remote FTP or SCP storage.
NOTE: This field is only required when $config['backup_destination'] is set to ftp, passiveftp or scp.
ftpusername
$config['backup_pass'] The password required to access the remote FTP or SCP storage.
NOTE: This field is only required when $config['backup_destination'] is set to ftp, passiveftp or scp.
ftppassword
$config['backup_rdir'] This is the file path on the remote server to store the backups.
NOTE: Please note this folder path must exist.
NOTE: This field is only required when $config['backup_destination'] is set to ftp, passiveftp or scp.
/
$config['max_backups_per_account'] This will set the maximum number of backups to keep for each account found on the FTP server.
NOTE: This only has to be set if you are using the "ftp_retention.php" script.
NOTE: Please note this checks for files with the following name format "backup-MONTH.DAY.YEAR_HOUR-MINUTE-SECOND_USERNAME.tar.gz". Therefore if backups from other servers are stored in the same folder the script may also remove those backups in line with this retention setting.
3

If you have any queries with configuring the script please look at our troubleshooting guide below, email me peter@whmbackup.solutions or contact me via the facebook page https://www.facebook.com/whmbackupsolutions/.


Troubleshooting Guide

Coming Soon.


Issue Tracking

To ensure all our issues are identified and logged, we use a public tracker system embedded into BitBucket where our GIT repository is stored.

The issue tracker can be found here, if you identify an issue please work through our troubleshooting guide and check if the issue has already been raised on our issue tracker before logging a new issue.