$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!