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. If you want to use multiple configuration files please see our guide below.
|$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. 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. Checking for updates will also enable automatic script upgrading. To disable automatic script updates add the following to your config file. $config[“skip_update”] = ‘1’;||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 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.||[email protected]|
|$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. 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. 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. 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. This field is only required when $config[‘backup_destination’] is set to ftp, passiveftp or scp.||ftppassword|
|$config[‘backup_scp_key_name’]||The key name of the SSH key that has been imported into your cPanel.||keyname|
|$config[‘backup_scp_key_passphrase’]||The passphrase of the SSH key that has been imported into your cPanel.||mysecretpassword|
|$config[‘backup_rdir’]||This is the file path on the remote server to store the backups. Please note this folder path must exist. This field is only required when $config[‘backup_destination’] is set to ftp, passiveftp or scp.||/|
|$config[‘skip_ftp_verification’]||If you are using FTP or PassiveFTP as the backup destination, by default the script performs a check to see if the server your running the backup script from can login and access the FTP server, it also checks and/or creates the necessary directory. Setting this configuration value to 1 will skip all these checks. This may be required if the reseller your backing up is remote to the server this script is running from.||0|
|$config[‘skip_ftp_directory_creation’]||If you are using FTP or PassiveFTP as the backup destination, by default the script performs a check to see if the server your running the backup script from can login and access the FTP server, it also checks and/or creates the necessary directory. Setting this configuration value to 1 will skip the creation of the FTP directory only. This may be required if the reseller your backing up is remote to the server this script is running from.||0|
|$config[“force_version”]||By default the script will automatically detect the cPanel version and decide the best API method to use, API1 or UAPI. To force the backup script to use API1 set this to 1 or for UAPI set this to 3. For automatic detection remove this configuration variable.|
|FTP Retention Settings
The following settings only have to be set if you are using the “ftp_retention.php” script.
|$config[‘max_backups_per_account’]||This will set the maximum number of backups to keep for each account found on the FTP server.
This only has to be set if you are using the “ftp_retention.php” script.
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.
|$config[‘ftp_retention_rdir’]||If you store backups in a folder that is separate to the directory set in $config[‘backup_rdir’]. You can override the directory to check for backups in using this setting.||/ftproot/folder1/|
|$config[‘ftp_retention_skip_sub_directories’]||By default the ftp retention script will search all sub-directories of the path specified in $config[‘backup_rdir’] or $config[‘ftp_retention_rdir’]. To limit the script to not search any sub-directories, set this to 1.||1|
Multiple Configuration Files
To run multiple configuration files create each config, save them in the root folder of the backup script and name them config-NAME.php. NAME is to be replaced with a single alphanumeric word of your choice, please note NAME can not be set to “generate” or “force” as these variables are reserved for other functionality in the script.
To then run the script using your new config you simply add config= and then the NAME of the config to the cron job as shown below. This applies to both the ftp_retention.php and whmbackup.php.
php -q /home/user/whmbackupsolutions/whmbackup.php config=NAME php -q /home/user/whmbackupsolutions/whmbackup.php config=NAME generate php -q /home/user/whmbackupsolutions/ftp_retention.php config=NAME
Still having issues with the script? Check out our Troubleshooting guide.