forked from projects/fipamo
added additional asset folders to back up script
the current file backup included images, but the additional asset types such as sound files, video and docs were not being added if they existed, so those have been added. also tweaked the front end script to include the correct token for the API so the backup request doesn't fail the auth check
This commit is contained in:
parent
4520c9b608
commit
d51071b2d3
2 changed files with 20 additions and 31 deletions
|
@ -8,10 +8,14 @@ use Carbon\Carbon;
|
|||
class MaintenanceService
|
||||
{
|
||||
protected $settings;
|
||||
protected $filePaths = [];
|
||||
|
||||
public function __construct(SettingsService $settingsService)
|
||||
{
|
||||
$this->settings = $settingsService;
|
||||
$this->filePaths = ['../public/assets/images/blog',
|
||||
'../public/assets/images/user', '../public/assets/docs/blog',
|
||||
'../public/assets/video/blog', '../public/assets/sound/blog'];
|
||||
}
|
||||
|
||||
public function createContentBackUp()
|
||||
|
@ -133,38 +137,23 @@ class MaintenanceService
|
|||
\ZipArchive::CREATE | \ZipArchive::OVERWRITE
|
||||
);
|
||||
//gather data and path info for blog images
|
||||
$blogImagesPath = '../public/assets/images/blog';
|
||||
$yearPaths = glob($blogImagesPath . '/*', GLOB_ONLYDIR);
|
||||
foreach ($yearPaths as $years) {
|
||||
$year = explode('/', $years);
|
||||
$monthsPath = glob($blogImagesPath . '/' . $year[5] . '/*', GLOB_ONLYDIR);
|
||||
foreach ($monthsPath as $months) {
|
||||
$month = explode('/', $months);
|
||||
//once info is collected, add images pages to zip
|
||||
$options = [
|
||||
'add_path' => 'public/assets/images/blog/' . $year[5] . '/' . $month[6] . '/',
|
||||
'remove_all_path' => true,
|
||||
];
|
||||
$zip->addGlob($months . '/*.*', GLOB_BRACE, $options);
|
||||
}
|
||||
}
|
||||
|
||||
//gather data and path info for user images
|
||||
$userImagesPath = '../public/assets/images/user';
|
||||
$yearPaths = glob($userImagesPath . '/*', GLOB_ONLYDIR);
|
||||
foreach ($this->filePaths as $path) {
|
||||
$yearPaths = glob($path . '/*', GLOB_ONLYDIR);
|
||||
foreach ($yearPaths as $years) {
|
||||
$year = explode('/', $years);
|
||||
$monthsPath = glob($userImagesPath . '/' . $year[5] . '/*', GLOB_ONLYDIR);
|
||||
$monthsPath = glob($path . '/' . $year[5] . '/*', GLOB_ONLYDIR);
|
||||
foreach ($monthsPath as $months) {
|
||||
$month = explode('/', $months);
|
||||
//once info is collected, add images pages to zip
|
||||
$options = [
|
||||
'add_path' => 'public/assets/images/user/' . $year[5] . '/' . $month[6] . '/',
|
||||
'add_path' => substr($path, 3) . '/' . $year[5] . '/' . $month[6] . '/',
|
||||
'remove_all_path' => true,
|
||||
];
|
||||
$zip->addGlob($months . '/*.*', GLOB_BRACE, $options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$zip->close();
|
||||
$this->settings->updateGlobalData('last_files_backup', $stamp);
|
||||
|
|
|
@ -281,7 +281,7 @@ class MaintenanceManager {
|
|||
}
|
||||
};
|
||||
if (requestType == REQUEST_TYPE_PUT || requestType == REQUEST_TYPE_POST) {
|
||||
if (eventType === TASK_UPLOAD_FILES)
|
||||
if (eventType === TASK_UPLOAD_FILES || eventType === TASK_BACKUP_CREATE)
|
||||
request.setRequestHeader('fipamo-access-token', self.token);
|
||||
switch (contentType) {
|
||||
case CONTENT_TYPE_JSON:
|
||||
|
|
Loading…
Reference in a new issue