/ Published in: PHP
Save this file as a .php somewhere on your webserver - NOT A WEB ACCESSIBLE LOCATION! Edit the lines in the top portion to suit your needs and call the file from bash like this: $> php cpanel-backup.php
You can use a cronjob to make this run automatically!
You can use a cronjob to make this run automatically!
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php // PHP script to allow periodic cPanel backups automatically, optionally to a remote FTP server. // This script contains passwords. KEEP ACCESS TO THIS FILE SECURE! (place it in your home dir, not /www/) // ********* THE FOLLOWING ITEMS NEED TO BE CONFIGURED ********* // Info required for cPanel access $cpuser = "username"; // Username used to login to CPanel $cppass = "password"; // Password used to login to CPanel $domain = "domain.com"; // Domain name where CPanel is run $skin = "x"; // Set to cPanel skin you use (script won't work if it doesn't match). Most people run the default x theme // Info required for FTP host $ftpuser = "username"; // Username for FTP account $ftppass = "password"; // Password for FTP account $ftphost = "ftp.domain.com"; // Full hostname or IP address for FTP host $ftpmode = "ftp"; // FTP mode ("ftp" for active, "passiveftp" for passive) // Notification information // Secure or non-secure mode $secure = 1; // Set to 1 for SSL (requires SSL support), otherwise will use standard HTTP // Set to 1 to have web page result appear in your cron log $debug = 1; // *********** NO CONFIGURATION ITEMS BELOW THIS LINE ********* if ($secure) { $url = "ssl://".$domain; $port = 2083; } else { $url = $domain; $port = 2082; } // Encode authentication string $authstr = $cpuser.":".$cppass; $params = "dest=$ftpmode&email=$notifyemail&server=$ftphost&user=$ftpuser&pass=$ftppass&submit=Generate Backup"; // Make POST to cPanel "); "); "); "); "); // Grab response even if we don't do anything with it. if ($debug) echo $response; } ?>
URL: http://www.arnoldb.com/2009/07/21/cpanel-full-site-backup-with-php/