$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 и всех подкаталогов в ней. Он создает файл tar.gz в папке / public_html / backups /. PHP-скрипт также запускается из папки / public_html / backups /. Любая идея о том, как ограничить то, что сохраняется из '/' в '/ public_html /'? Спасибо!