Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cdsalmons/02af1d54e991e6f3aa3f to your computer and use it in GitHub Desktop.
Save cdsalmons/02af1d54e991e6f3aa3f to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use cPanel::PublicAPI;
use Getopt::Long;
&Getopt::Long::config('bundling');
# Options args
my $conf = GetOptions(
"H|hostname=s" => \$conf_host,
"P|port=i" => \$conf_port,
"u|username=s" => \$conf_user,
"p|password=s" => \$conf_pass,
);
# FTP Configuration
my $config = {
'folder_name' => '/data/cpbackups',
'ftp_host' => 'ftp.mysite.com',
'ftp_user' => 'username',
'ftp_pass' => 'password',
'ftp_port' => '21',
'ftp_mail' => '[email protected]', # Change this for backup completion alerts / debugging
'version' => 'v1.6',
};
if ( ( !$conf_host ) or ( !$conf_user ) or ( !$conf_pass ) ) {
print_usage();
}
if( ! $conf_port) {
$conf_port = "2083";
}
my $cp = cPanel::PublicAPI->new(
'user' => $conf_user,
'pass' => $conf_pass,
'host' => $conf_host,
'usessl' => '1',
'debug' => '0'
);
$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' => '%2F'
},
'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";
sub print_usage {
print <<EOU;
Dan Miller <dm\@sub6.com>
Version: $config->{'version'}
Usage: download_cpanel_backup.pl -H cpanel_hostname -u cpanel_username -p cpanel_password [ -p cpanel port ]
EOU
exit 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment