forked from ZwiiCMS-Team/ZwiiCampus
Livre un outil de mise à jour automatisé appelable par CRON
This commit is contained in:
parent
14683133c8
commit
d35010f100
26
core/module/config/tool/autobackup.php
Normal file
26
core/module/config/tool/autobackup.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
// Creation du ZIP
|
||||||
|
$filter = $filter = ['backup', 'tmp'];
|
||||||
|
$fileName = 'Campus-Rolling' . '-backup-' . date('Y-m-d-H-i-s', time()) . '.zip';
|
||||||
|
$zip = new ZipArchive();
|
||||||
|
$zip->open('../../../../site/backup/' . $fileName, ZipArchive::CREATE | ZipArchive::OVERWRITE);
|
||||||
|
$directory = '../../../../site';
|
||||||
|
$files = new RecursiveIteratorIterator(
|
||||||
|
new RecursiveCallbackFilterIterator(
|
||||||
|
new RecursiveDirectoryIterator(
|
||||||
|
$directory,
|
||||||
|
RecursiveDirectoryIterator::SKIP_DOTS
|
||||||
|
),
|
||||||
|
function ($fileInfo, $key, $iterator) use ($filter) {
|
||||||
|
return $fileInfo->isFile() || !in_array($fileInfo->getBaseName(), $filter);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
foreach ($files as $name => $file) {
|
||||||
|
if (!$file->isDir()) {
|
||||||
|
$filePath = $file->getRealPath();
|
||||||
|
$relativePath = substr($filePath, strlen(realpath($directory)) + 1);
|
||||||
|
$zip->addFile($filePath, $relativePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$zip->close();
|
Loading…
Reference in New Issue
Block a user