php自动备份vps网站目录
<?php
date_default_timezone_set('Asia/Shanghai');
$filename="bak".date("Ymd").".tar.gz";
shell_exec("tar -czf ".$filename." -C / srv");
$des='/root/down/bak/'.$filename;
$host='';
$hostport='';
$user='';
$pwd='';
$remotedir='../srv/bak/';
$ftpconn=ftp_connect($host,'21') or die ("ftp connect error");
$login = ftp_login($ftpconn,$user,$pwd);
ftp_chdir($ftpconn,$remotedir);
ftp_pasv($ftpconn,false);
$res=ftp_put($ftpconn,$filename,'/root/'.$filename,FTP_BINARY) or die ('upload error');
ftp_close($ftpconn);
rename('/root/'.$filename,$des);
echo 'Done.';
?>
发表于 2018-06-07 02:58:00 并被添加「」标签,阅读量: 751 。
此处评论已关闭