/** * Perform backup * @return string */ public static function createBackup() { if (!self::createBackupDirectory()) { return self::error('Failed to create backup directory'); } $locations = App::getDirectories(); $exclusions = App::getExcludeDirectories(); foreach ($locations as $type => $path) { if (!self::copyPath($path, $type, $exclusions)) { return self::error('Failed to copy ' . $type); } } return self::getBackupPath(); }
public static function update($sourcePath, $backupPath) { if (!is_dir($backupPath)) { return self::error('Backup directory is not found'); } self::$_updateDirs = App::getDirectories(); self::$_skipDirs = App::getExcludeDirectories(); set_include_path($backupPath . PATH_SEPARATOR . $backupPath . DIRECTORY_SEPARATOR . 'lib' . PATH_SEPARATOR . $backupPath . DIRECTORY_SEPARATOR . 'config' . PATH_SEPARATOR . $backupPath . DIRECTORY_SEPARATOR . '3rdparty' . PATH_SEPARATOR . $backupPath . '/apps' . PATH_SEPARATOR . get_include_path()); $tempPath = App::getBackupBase() . 'tmp'; if (!@mkdir($tempPath, 0777, true)) { return self::error('failed to create ' . $tempPath); } self::moveDirectories($sourcePath, $tempPath); $config = "/config/config.php"; copy($tempPath . $config, self::$_updateDirs['core'] . $config); return true; }