Jump to content

File-Backup script (using Gzip)


Goldeneye

Recommended Posts

I've created a script that reads the base-directory (where the core-files of my site are found) for PHP-Files. It does that part perfectly. What it doesn't execute correctly is making a valid Gzip-Compressed Tarball that can be successfully opened to show the PHP-Files. What exactly is wrong with this code-snippet?

 

<?php
$dir = opendir('.');

while($name = readdir($dir))
	if($name != '.' && $name != '..' && (is_file($name)===true)) $files[] = $name;

$fp = fopen(date('Y-m-d').'.tar.gz', 'w');

foreach($files as $file){
	$data = implode('', file($file));
	$gzdata = gzencode($data, 9);
	fwrite($fp, $gzdata);
}

fclose($fp);
?>

Link to comment
https://forums.phpfreaks.com/topic/171998-file-backup-script-using-gzip/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.