how to implement tar command through php script?

Recommended Answers

All 3 Replies

Like this:

$script = "tar -czf $backupdir/DATABASE-$dbname.tgz $backupdir/$dbname.sql";
 $results = system($script,$retval);
 echo "\n CREATE TAR FILE:\n $results\n RETURN VALUE: $retval\n";

Obviously fill in the $variables as needed.

but I use it for a backup of mysql db;s

Like this:

$script = "tar -czf $backupdir/DATABASE-$dbname.tgz $backupdir/$dbname.sql";
 $results = system($script,$retval);
 echo "\n CREATE TAR FILE:\n $results\n RETURN VALUE: $retval\n";

Obviously fill in the $variables as needed.

but I use it for a backup of mysql db;s

your file was .tgz extension. for me it is tar.gz. and i think you are compressing it, wh abt extracting the files. i have been trying with syntax like this
$output=shell_exec("cd /dir ; gunzip {$path}; ");
$path is the variable used in uploading the file
what after that?

here is the solution. If you don't know the filename nad it is stored in some php variable
let $filename=x.tar.gz

shell_exec("cd destination_directory; gunzip {$filename}| tar xf -;");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.