Skip to content

Instantly share code, notes, and snippets.

@rickscherer
Created May 15, 2015 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rickscherer/a041b56627b28c21914f to your computer and use it in GitHub Desktop.
Save rickscherer/a041b56627b28c21914f to your computer and use it in GitHub Desktop.
Perl script using cPanel Public API 1.0 to perform automated full backup of entire site to external FTP server. Make sure cPanel::PublicAPI 1.0 is loaded.
#!/usr/bin/perl
use cPanel::PublicAPI;
my $config = {
'folder_name' => '/Backup', # Change to the folder on your FTP server
'ftp_host' => 'ftp.vmwaretips.com', # Change to your FTP server fqdn/IP
'ftp_user' => 'username', # Change to your FTP username
'ftp_pass' => 'password', # Change to your FTP password
'ftp_port' => '21', # Change to your FTP port number
'ftp_mail' => 'rick@vmwaretips.com', # Change this for backup completion alerts / debugging
'version' => 'v1.0',
};
if( ! $conf_port) {
$conf_port = "2083"; # Change to your cPanel port (2083 is SSL default)
}
my $cp = cPanel::PublicAPI->new(
'user' => 'username', # Change to your cPanel username
'pass' => 'password', # Change to your cPanel password
'host' => 'vmwaretips.com', # Change to your fqdn where cPanel is running
'usessl' => '1', # If using SSL leave this 1 (port 2083 is default)
'debug' => '0' # Change to 1 to enable debugging
);
$cp->cpanel_api1_request('cpanel',
{
'cpanel_xmlapi_user' => $conf_user,
'module' => 'Fileman',
'func' => 'fullbackup'
},
{
'arg-0' => 'ftp',
'arg-1' => $config->{'ftp_host'},
'arg-2' => $config->{'ftp_user'},
'arg-3' => $config->{'ftp_pass'},
'arg-4' => $config->{'ftp_mail'},
'arg-5' => $config->{'ftp_port'},
'arg-6' => $config->{'folder_name'},
},
'xml'
);
print "---";
print "\nYour backup will be stored in $config->{'folder_name'}/ - You will be notified at $config->{'ftp_mail'} when this process completes.\n";
print "---\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment