41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
// Archivia in ZIP la cartella modulo_certificazione (backup)
|
|
// NB: il vecchio blocco di dump database è stato rimosso perché conteneva
|
|
// credenziali in chiaro ed era disattivato. Se serve un dump DB,
|
|
// usare mysqldump o un comando artisan dedicato.
|
|
|
|
ignore_user_abort(true);
|
|
set_time_limit(3600);
|
|
|
|
$main_path = '../modulo_certificazione';
|
|
$zip_file = '../tempbck//cimac.tar';
|
|
|
|
if (file_exists($main_path) && is_dir($main_path)) {
|
|
$zip = new ZipArchive();
|
|
|
|
if (file_exists($zip_file)) {
|
|
unlink($zip_file); // truncate ZIP
|
|
}
|
|
if ($zip->open($zip_file, ZIPARCHIVE::CREATE) !== TRUE) {
|
|
die("cannot open <$zip_file>\n");
|
|
}
|
|
|
|
$files = 0;
|
|
$paths = array($main_path);
|
|
|
|
while (list(, $path) = each($paths)) {
|
|
foreach (glob($path . '/*') as $p) {
|
|
if (is_dir($p)) {
|
|
$paths[] = $p;
|
|
} else {
|
|
$zip->addFile($p);
|
|
$files++;
|
|
echo $p . "<br>\n";
|
|
}
|
|
}
|
|
}
|
|
|
|
echo 'Total files: ' . $files;
|
|
$zip->close();
|
|
}
|