• Steam recently changed the default privacy settings for all users. This may impact tracking. Ensure your profile has the correct settings by following the guide on our forums.

[PHP] Backup Your Site

x3sphere

Administrator
Staff member
Enforcer Team
Game Info Editor
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.
 

Cheezeball99

But I was committed after that birthday party...
I need to learn more PHP. I know very little/none. Make some PHP tuts, d00d! I mean, it ain't THAT bigga' deal, I'm sure I can find some, but it'd be cool.:smile:
 
Top