用PHP实现cPanel到异地FTP的自动全站备份
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用PHP实现cPanel到异地FTP的自动全站备份相关的知识,希望对你有一定的参考价值。
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.phpYou can use a cronjob to make this run automatically!
<?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; } ?>
以上是关于用PHP实现cPanel到异地FTP的自动全站备份的主要内容,如果未能解决你的问题,请参考以下文章