Take cPanel full backup-PHP
Hello Friends !!
I found some new thing to take backup your site/blog from server.
I give you script to take backup.
This will take full backup from cPanel to FTP.
The first, cpbackup_cfg.php, shown below, must be edited to insert your site and FTP server login credentials.
$cpuser = “xxxxxxxxxx”;
$cppass = “xxxxxxxxxx”;
$domain = “yourdomain.com”;
$skin = “x2″;
$ftpuser = “xxxxxxxx”;
$ftppass = “xxxxxxxx”;
$ftphost = “ftp.backupsite.com”;
$ftpmode = “passiveftp”;
$ftpdir = “/subdir”;
$notifyemail = “webmaster@mydomain.com”;
$delbackup = 1;
$secure = 0;
$debug = 0;
?>
The second file, cp_backup.php, shown below, is the backup script itself.
include(‘cpbackup_cfg.php’);
if ($secure) {
$url = “ssl://”.$domain;
$port = 2083;
} else {
$url = $domain;
$port = 2082;
}
if ($delbackup) {
$conn_id = ftp_connect($ftphost);
if ($conn_id) {
$ok = ftp_login($conn_id, $ftpuser, $ftppass);
if ($ok) {
if (!empty($ftpdir)) {
$ok = ftp_chdir($conn_id,$ftpdir);
}
if ($ok) {
$dirlist = ftp_nlist($conn_id, “backup*”);
if (!empty($dirlist[0])) @ftp_delete($conn_id,$dirlist[0]);
}
}
ftp_close($conn_id);
}
}
$socket = fsockopen($url,$port);
if (!$socket) { echo “Cannot connect to $url\n”; exit; }
$authstr = $cpuser.”:”.$cppass;
$pass = base64_encode($authstr);
$request_data = “dest=”.urlencode($ftpmode).”&email=”.urlencode($notifyemail);
$request_data .= “&server=”.urlencode($ftphost).”&user=”.urlencode($ftpuser);
$request_data .= “&pass=”.urlencode($ftppass);
if (!empty($ftpdir)) $request_data .= “&rdir=”.urlencode($ftpdir);
$request_data .= “&submit=”.urlencode(‘Generate Backup’);
fputs($socket,”POST /frontend/”.$skin.”/backup/dofullbackup.html HTTP/1.1\r\n”);
fputs($socket,”Host: $domain\r\n”);
fputs($socket,”Authorization: Basic $pass\r\n”);
fputs($socket,”Content-type: application/x-www-form-urlencoded\r\n”);
fputs($socket,”Content-length: “.strlen($request_data).”\r\n\r\n”.$request_data);
while (!feof($socket)) {
$response = fgets($socket,4096);
if ($debug) echo $response;
}
fclose($socket);
?>
After this run cp_backup.php file. It will create zip file in root folder.
If you have any query then post comment.
THanks…
-
http://www.cPanel.net/ David Grega
-
http://www.cPanel.net David Grega
-
admin
-
admin
-
http://www.dailytuts.net/4579-take-cpanel-full-backup-php/ Take cPanel full backup-PHP | Dailytuts.net – Daily tutorial for peoples
-
http://www.linkwayhosting.com linkway hosting
-
http://www.linkwayhosting.com linkway hosting
-
http://www.linkwayhosting.com linkway hosting




