PHP备份脚本仅备份public_html
$filename= "Backup.tar"; // The name (and optionally path) of the dump file
$ftp_server = "IP"; // Name or IP. Shouldn't have any trailing slashes and shouldn't be prefixed with ftp://
$ftp_port = "21"; // FTP port - blank defaults to port 21
$ftp_username = "User"; // FTP account username
$ftp_password = "Pass"; // FTP account password - blank for anonymous
$filename = "public_html/backups/" . $filename . ".gz";
$command = "tar cvf ~/$filename ~/*";
$result = exec($command);
$command = "gzip -9 -S .gz ~/$filename";
$result = exec($command);
这是我使用的工作备份。它备份服务器上的所有内容,包括电子邮件(例如/mail/。我只想备份/public_html文件夹及其下的所有子目录。它在/public_html/backups/文件夹中创建一个tar.gz文件。PHP脚本也从 /public_html/backups/ 文件夹运行。关于如何限制从 '/' 保存到 '/public_html/' 的内容,有什么想法吗?
$filename= "Backup.tar"; // The name (and optionally path) of the dump file
$ftp_server = "IP"; // Name or IP. Shouldn't have any trailing slashes and shouldn't be prefixed with ftp://
$ftp_port = "21"; // FTP port - blank defaults to port 21
$ftp_username = "User"; // FTP account username
$ftp_password = "Pass"; // FTP account password - blank for anonymous
$filename = "public_html/backups/" . $filename . ".gz";
$command = "tar cvf ~/$filename ~/*";
$result = exec($command);
$command = "gzip -9 -S .gz ~/$filename";
$result = exec($command);
This is my working backup that I use. It backs up everything on the server including emails (for example /mail/. I only want to backup the /public_html folder and all subdirectories under it. It creates a tar.gz file in the /public_html/backups/ folder. The PHP script also runs from the /public_html/backups/ folder. Any idea on how to restrict what is saved from '/' to '/public_html/' ? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只需要更改 tar 命令的第三个输入
you just need to change the third input of the tar command