/ Published in: PHP
This is a php script to trigger a cpanel full backup to the servers home directory OR a remote ftp server
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /* * fullbackup.php * This is a php script to trigger a cpanel full backup to the servers home directory OR a remote ftp server * KEEP ACCESS TO THIS FILE SECURE! * Because this file contains passwords, it is safest located in the highest level root above /www/ or /public_html/ */ 'user' => '', // cpanel username 'pass' => '', // cpanel password 'domain' => '.com', // address to server running cpanel 'skin' => 'rvskin' ), // 'rvskinlight' for cpanel at https://example.com:2083/frontend/rvskinlight/index.html 'enabled' => false, // true: backup to a remote server using settings below, false: ignore settings below and backup to home directory 'user' => '', // ftp username 'pass' => '', // ftp password 'host' => 'ftp.example.com', // address to ftp server 'mode' => 'passiveftp', // must be 'ftp', 'passiveftp' (most common), or 'scp' 'port' => '21', // usually '21' for passiveftp 'dir' => '' ), // (optional) existing subdirectory on ftp server 'email' => '@gmail.com', // (optional) an email will be sent to this address when the backup is finished 'ssl' => false, // must be true if this script is not on the same server as cpanel 'log' => false ); // output error/success messages to cron log? $socket = fsockopen( ($options['ssl'] ? 'ssl:' : '') . $options['cpanel']['domain'], ($options['ssl'] ? 2083 : 2082) ); if( !$socket ) { if ($options['log']) echo "Failed to open socket connection... Exiting script!\n"; // cron log } // generate specific query for remote server or home directory if ($options['ftp']['enabled']) $query = 'dest=' . $options['ftp']['mode'] . '&server=' . $options['ftp']['host'] . '&user=' . $options['ftp']['user'] . '&pass=' . $options['ftp']['pass'] . '&port=' . $options['ftp']['port']. '&rdir=' . $options['ftp']['dir']; else $query = 'dest=homedir'; // tack on the variables required by any query $query .= '&email=' . $options['email'] . '&submit=Generate Backup'; // simluate post to 'dofullbackup.html' in cpanel fwrite( $socket, 'POST /frontend/' . $options['cpanel']['skin'] . '/backup/dofullbackup.html?' . $query . " HTTP/1.0 " ); " ); fwrite( $socket, 'Authorization: Basic ' . base64_encode( $options['cpanel']['user'] . ':' . $options['cpanel']['pass'] ) . " " ); " ); if ($options['log']) echo $response; // cron log ?>
URL: http://www.justin-cook.com/wp/2006/12/27/automatic-cpanel-backup-domain-mysql-with-cron-php/