


CPanel panel uses PHP to automatically back up website files_PHP tutorial
The CPanel panel is a very powerful virtual host management panel. If you are a space business owner, you may be familiar with this CP panel. Now I will introduce how to use PHP to automatically back up website files.
代码如下 | 复制代码 |
// PHP script to allow periodic cPanel backups automatically. // Based on script posted by max.hedroom in cpanel.net forums // This script contains passwords. KEEP ACCESS TO THIS FILE SECURE! // ********* 下面项目需要设定 ********* // cPanel登录信息 $cpuser = "**"; // CPanel帐号 $cppass = "***"; // CPanel密码 $domain = "***"; // cPanel所在域名或IP $skin = "x3"; // 正在使用的cPanel风格,默认"x3"。 /************** 备份目的地 *************** "homedir" - 本地主目录 "ftp" - 远程FTP备份(主动模式) "passiveftp" - 远程FTP备份(被动模式) "scp" - 加密传输(需服务器支持) ****************************************/ $savedir = "ftp"; // 备份目的地,默认"homedir",即只做本地备份。 // FTP上传的信息(备份目的地为本地的,可不填) $ftpuser = "***"; // FTP帐号 $ftppass = "***!"; // FTP密码 $ftphost = "***"; // FTP服务器IP $ftpport = "21"; // FTP端口,默认21 $ftprdir = "/"; // 远程FTP目录,默认"/" // 通知信息 $notifyemail = "**@gmail.com"; // 信息反馈邮件地址 // 安全模式 $secure = 1; // 0为标准http, 1为ssl(需要主机支持ssl) // 设定值为1时会在排程记录中产生网页报告 $debug = 0; // *********** 以下内容不要更改! ********* if ($secure) { $url = "ssl://".$domain; $port = 2083; } else { $url = $domain; $port = 2082; } $socket = fsockopen($url,$port); if (!$socket) { echo "Failed to open socket connection... Bailing out!n"; exit; } // Encode authentication string $authstr = $cpuser.":".$cppass; $pass = base64_encode($authstr); $params = "dest=$savedir&email=$notifyemail&server=$ftphost&user=$ftpuser&pass=$ftppass&port=$ftpport&rdir=$ftprdir&submit=Generate Backup"; // Make POST to cPanel fputs($socket,"POST /frontend/".$skin."/backup/dofullbackup.html?".$params." HTTP/1.0rn"); fputs($socket,"Host: $domainrn"); fputs($socket,"Authorization: Basic $passrn"); fputs($socket,"Connection: Closern"); fputs($socket,"rn"); // Grab response even if we don't do anything with it. while (!feof($socket)) { |
Copy the above code and save it as: fullbackup.php file, upload it to a directory other than public_html
This global script contains the cPanel login account and password. For security reasons, you need to put this script in a folder other than the public_html folder, such as: "/home/yourname/backup", and set the folder's The permissions are 600. Remember!
2. Fill in the relevant information and change the file name to fullbackup.php
3. Upload the above script to the "/home/yourdomain/beifen" directory. (If there is no beifen directory, you can create a new one)
4. Change the permissions of the beifen directory to 600
5. Open the Cron Jobs in the cpanel panel.
Select the job frequency and enter
in the command field The code is as follows
|
Copy code | ||||

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP is an open source MVC framework. It makes developing, deploying and maintaining applications much easier. CakePHP has a number of libraries to reduce the overload of most common tasks.

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op
