Simple PHP script to Tar a folder

Here it is…

<?php
$path = explode("/",realpath('./'));
$filename = date("Y-m-d_His") . "_" . array_pop($path);
echo "<pre>Compressing ./* to ../${filename}.tgz</pre>";
$output = shell_exec('tar -cvz --exclude "./dotar.php" -f ../' . $filename . '.tgz ./*');
echo "<pre>$output</pre>";
echo "<pre>Done.</pre>";
?>

Leave a Reply

Your email address will not be published. Required fields are marked *