This will create a tar.gz archive on the fly of the directory you're running the PHP script from.
[highlight=php]<?php
// get current working directory
$dir = getcwd();
// start headers
header('Content-Type: application/x-gzip');
$content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT) == 'IE') ? 'inline' : 'attachment';
header('Content-Disposition: ' . $content_disp . '; filename="backup.tar.gz"');
header('Pragma: no-cache');
header('Expires: 0');
// create the backup
passthru( "tar cz $dir");
?>[/highlight]
Useful for when you want to create a quick backup of a certain directory on your site. Of course leaving the file on your server is dangerous, either password protect it or delete the file once you've finished.
[highlight=php]<?php
// get current working directory
$dir = getcwd();
// start headers
header('Content-Type: application/x-gzip');
$content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT) == 'IE') ? 'inline' : 'attachment';
header('Content-Disposition: ' . $content_disp . '; filename="backup.tar.gz"');
header('Pragma: no-cache');
header('Expires: 0');
// create the backup
passthru( "tar cz $dir");
?>[/highlight]
Useful for when you want to create a quick backup of a certain directory on your site. Of course leaving the file on your server is dangerous, either password protect it or delete the file once you've finished.