.htaccess
1 year ago
Progress.php
1 year ago
Queue.php
5 months ago
QueueItem.php
1 day ago
QueueItemBackup.php
5 months ago
QueueItemDownload.php
1 year ago
QueueItemExport.php
1 year ago
QueueItemExtract.php
1 year ago
QueueItemReindex.php
1 year ago
QueueItemRestore.php
1 year ago
QueueItemRetentionCleanup.php
1 year ago
QueueItemSystem.php
1 year ago
aQueueItem.php
1 year ago
index.html
1 year ago
web.config
1 year ago
QueueItemRestore.php
93 lines
| 1 | <?php |
| 2 | |
| 3 | namespace JetBackup\Queue; |
| 4 | |
| 5 | if (!defined('__JETBACKUP__')) die('Direct access is not allowed'); |
| 6 | |
| 7 | class QueueItemRestore extends aQueueItem { |
| 8 | |
| 9 | const SNAPSHOT_ID = 'snapshot_id'; |
| 10 | const SNAPSHOT_PATH = 'snapshot_path'; |
| 11 | const QUEUE_GROUP_ID = 'queue_group_id'; |
| 12 | const RESTORE_URL = 'restore_url'; |
| 13 | const OPTIONS = 'options'; |
| 14 | const EXCLUDE_DATABASE = 'exclude_database'; |
| 15 | const INCLUDE_DATABASE = 'include_database'; |
| 16 | const EXCLUDE = 'exclude'; |
| 17 | const INCLUDE = 'include'; |
| 18 | const ADMIN_USER = 'admin_user'; |
| 19 | const FILE_MANAGER = 'file_manager'; |
| 20 | |
| 21 | // General restore |
| 22 | const OPTION_RESTORE_DATABASE_ENTIRE = 1 << 0; // import full db dump, no includes/excludes |
| 23 | const OPTION_RESTORE_FILES_ENTIRE = 1 << 1; // restore full homedir path, no includes/excludes |
| 24 | |
| 25 | // Multisite Restore Types |
| 26 | const OPTION_MULTISITE_ENTIRE_NETWORK = 1 << 2; |
| 27 | const OPTION_MULTISITE_SPECIFIC_SITE = 1 << 3; |
| 28 | |
| 29 | // Restore Methods |
| 30 | const OPTION_MULTISITE_AS_DOMAIN = 1 << 4; |
| 31 | const OPTION_MULTISITE_STAND_ALONE = 1 << 5; |
| 32 | |
| 33 | // Database Restore Options |
| 34 | |
| 35 | const OPTION_RESTORE_DATABASE_EXCLUDE = 1 << 6; // restore tables, without excluded listed |
| 36 | const OPTION_RESTORE_DATABASE_SKIP = 1 << 7; // DO NOT restore database (skip the step) |
| 37 | const OPTION_RESTORE_DATABASE_INCLUDE = 1 << 8; // restore only selected db tables |
| 38 | |
| 39 | // Files Restore Options |
| 40 | const OPTION_RESTORE_FILES_EXCLUDE = 1 << 9; // restore homedir, without excluded listed |
| 41 | const OPTION_RESTORE_FILES_SKIP = 1 << 10; // DO NOT restore database (skip the step) |
| 42 | const OPTION_RESTORE_FILES_INCLUDE = 1 << 11; // restore only selected files/folders |
| 43 | |
| 44 | public function setSnapshotId(int $_id): void { $this->set(self::SNAPSHOT_ID, $_id); } |
| 45 | public function getSnapshotId(): int { return (int) $this->get(self::SNAPSHOT_ID, 0); } |
| 46 | |
| 47 | public function setSnapshotPath(string $path): void { $this->set(self::SNAPSHOT_PATH, $path); } |
| 48 | public function getSnapshotPath(): string { return $this->get(self::SNAPSHOT_PATH); } |
| 49 | |
| 50 | public function setQueueGroupId(string $id): void { $this->set(self::QUEUE_GROUP_ID, $id); } |
| 51 | public function getQueueGroupId(): string { return $this->get(self::QUEUE_GROUP_ID); } |
| 52 | |
| 53 | public function setRestoreURL(string $url): void { $this->set(self::RESTORE_URL, $url); } |
| 54 | public function getRestoreURL(): string { return $this->get(self::RESTORE_URL); } |
| 55 | |
| 56 | public function setOptions(int $options): void { $this->set(self::OPTIONS, $options); } |
| 57 | public function getOptions(): int { return $this->get(self::OPTIONS, 0); } |
| 58 | |
| 59 | public function setExcludes(array $exclude): void { $this->set(self::EXCLUDE, $exclude); } |
| 60 | public function getExcludes(): array { return $this->get(self::EXCLUDE, []); } |
| 61 | public function setIncludes(array $include): void { $this->set(self::INCLUDE, $include); } |
| 62 | public function getIncludes(): array { return $this->get(self::INCLUDE, []); } |
| 63 | |
| 64 | public function setAdminUser(string $user): void { $this->set(self::ADMIN_USER, $user); } |
| 65 | public function getAdminUser(): string { return $this->get(self::ADMIN_USER); } |
| 66 | |
| 67 | public function setExcludedDatabases(array $exclude): void { $this->set(self::EXCLUDE_DATABASE, $exclude); } |
| 68 | public function getExcludedDatabases(): array { return $this->get(self::EXCLUDE_DATABASE, []); } |
| 69 | |
| 70 | public function setIncludedDatabases(array $include): void { $this->set(self::INCLUDE_DATABASE, $include); } |
| 71 | public function getIncludedDatabases(): array { return $this->get(self::INCLUDE_DATABASE, []); } |
| 72 | |
| 73 | public function setFileManager(array $files): void { $this->set(self::FILE_MANAGER, $files); } |
| 74 | public function getFileManager(): array { return $this->get(self::FILE_MANAGER, []); } |
| 75 | |
| 76 | public function isOption(int $option): bool { return ($this->getOptions() & $option); } |
| 77 | public function isRestoreDatabase(): bool { return !$this->isOption(self::OPTION_RESTORE_DATABASE_SKIP); } |
| 78 | public function isRestoreHomedir(): bool { return !$this->isOption(self::OPTION_RESTORE_FILES_SKIP); } |
| 79 | |
| 80 | public function getDisplay(): array { |
| 81 | return [ |
| 82 | self::SNAPSHOT_ID => $this->getSnapshotId(), |
| 83 | self::SNAPSHOT_PATH => $this->getSnapshotPath(), |
| 84 | self::QUEUE_GROUP_ID => $this->getQueueGroupId(), |
| 85 | self::RESTORE_URL => $this->getRestoreURL(), |
| 86 | self::OPTIONS => $this->getOptions(), |
| 87 | self::EXCLUDE => $this->getExcludes(), |
| 88 | self::EXCLUDE_DATABASE => $this->getExcludedDatabases(), |
| 89 | self::INCLUDE_DATABASE => $this->getIncludedDatabases(), |
| 90 | self::FILE_MANAGER => $this->getFileManager(), |
| 91 | ]; |
| 92 | } |
| 93 | } |