diff options
author | Simon Rettberg | 2023-03-08 15:38:45 +0100 |
---|---|---|
committer | Simon Rettberg | 2023-03-08 15:38:45 +0100 |
commit | e2d8c43c734adeb7c5a8ca5d90529874fcda15e0 (patch) | |
tree | 08429349f0f09ef75262df512cc57a3c63cc33c6 /modules-available/backup | |
parent | [backup] Check supplied backup file before trying to apply (diff) | |
download | slx-admin-e2d8c43c734adeb7c5a8ca5d90529874fcda15e0.tar.gz slx-admin-e2d8c43c734adeb7c5a8ca5d90529874fcda15e0.tar.xz slx-admin-e2d8c43c734adeb7c5a8ca5d90529874fcda15e0.zip |
[backup] Add option to store in /root, not just VMstore
Diffstat (limited to 'modules-available/backup')
-rw-r--r-- | modules-available/backup/hooks/cron.inc.php | 4 | ||||
-rw-r--r-- | modules-available/backup/inc/backuprestore.inc.php | 2 | ||||
-rw-r--r-- | modules-available/backup/page.inc.php | 13 | ||||
-rw-r--r-- | modules-available/backup/templates/_page.html | 18 |
4 files changed, 27 insertions, 10 deletions
diff --git a/modules-available/backup/hooks/cron.inc.php b/modules-available/backup/hooks/cron.inc.php index 529a3feb..7adbc0a4 100644 --- a/modules-available/backup/hooks/cron.inc.php +++ b/modules-available/backup/hooks/cron.inc.php @@ -12,6 +12,10 @@ $password = null; } if ($mode === BackupRestore::BACKUP_MODE_VMSTORE) { + if (file_exists('/srv/openslx/nfs/.notmounted')) { + EventLog::failure("Could not create automatic backup on VMstore as it's not mounted"); + return; + } $destination = '/srv/openslx/nfs/auto_backups/'; } else { $destination = '/root/auto_backups/'; diff --git a/modules-available/backup/inc/backuprestore.inc.php b/modules-available/backup/inc/backuprestore.inc.php index c34c86a2..931cbf26 100644 --- a/modules-available/backup/inc/backuprestore.inc.php +++ b/modules-available/backup/inc/backuprestore.inc.php @@ -4,9 +4,9 @@ class BackupRestore { const PROP_LAST_BACKUP = 'backup.last-time'; + const PROP_AUTO_BACKUP_PASS = 'backup.auto-passwd'; const PROP_AUTO_BACKUP_MODE = 'backup.auto-mode'; const BACKUP_MODE_ROOTHOME = 'ROOTHOME'; - const PROP_AUTO_BACKUP_PASS = 'backup.auto-passwd'; const BACKUP_MODE_VMSTORE = 'VMSTORE'; const BACKUP_MODE_OFF = 'OFF'; diff --git a/modules-available/backup/page.inc.php b/modules-available/backup/page.inc.php index 67be584f..9a2d08be 100644 --- a/modules-available/backup/page.inc.php +++ b/modules-available/backup/page.inc.php @@ -48,8 +48,8 @@ class Page_Backup extends Page 'id_color' => $bgcolor, 'id_prefix' => $title, 'last_backup' => $lastBackup, - 'autoBackupEnabled_checked' => Property::get(BackupRestore::PROP_AUTO_BACKUP_MODE, BackupRestore::BACKUP_MODE_OFF) - != BackupRestore::BACKUP_MODE_OFF ? 'checked' : '', + 'backup_' . Property::get(BackupRestore::PROP_AUTO_BACKUP_MODE, BackupRestore::BACKUP_MODE_OFF) + . '_checked' => 'checked', 'autoBackupPw' => Property::get(BackupRestore::PROP_AUTO_BACKUP_PASS, ''), ]; Permission::addGlobalTags($params['perms'], NULL, ['create', 'restore', 'config']); @@ -135,6 +135,7 @@ class Page_Backup extends Page $task = Taskmanager::waitComplete($task, 5000); @unlink($tempfile . '2'); if (Taskmanager::isFailed($task)) { + @unlink($tempfile); Util::redirect('?do=backup&errtaskid=' . $task['id']); } // Got uploaded file, now shut down all the daemons etc. @@ -191,8 +192,12 @@ class Page_Backup extends Page if (empty($password)) { $password = null; } - $mode = Request::post('auto-backup-enabled', 0, 'int') - ? BackupRestore::BACKUP_MODE_VMSTORE : BackupRestore::BACKUP_MODE_OFF; + $mode = Request::post('auto-backup-mode', false, 'string'); + if ($mode !== BackupRestore::BACKUP_MODE_OFF && $mode !== BackupRestore::BACKUP_MODE_ROOTHOME + && $mode !== BackupRestore::BACKUP_MODE_VMSTORE) { + Message::addError('invalid-auto-backup-mode', $mode); + Util::redirect('?do=backup'); + } Property::set(BackupRestore::PROP_AUTO_BACKUP_MODE, $mode); Property::set(BackupRestore::PROP_AUTO_BACKUP_PASS, $password); Util::redirect('?do=backup'); diff --git a/modules-available/backup/templates/_page.html b/modules-available/backup/templates/_page.html index 2fb89b18..74e20597 100644 --- a/modules-available/backup/templates/_page.html +++ b/modules-available/backup/templates/_page.html @@ -30,7 +30,7 @@ <input type="hidden" name="token" value="{{token}}"> <input type="hidden" name="action" value="restore"> <div class="panel panel-default"> - <div class="panel-heading">{{lang_restoreHeading}}{{#id_prefix}} – <b>{{.}}</b>{{/id_prefix}}</div> + <div class="panel-heading">{{id_prefix}} {{lang_restoreHeading}}</div> <div class="panel-body {{perms.restore.disabled}}" {{#id_color}}style="border:5px solid {{.}}"{{/id_color}}> <p>{{lang_restoreDescription}}</p> <label for="file-out">{{lang_restoreFileLabel}}</label> @@ -68,8 +68,8 @@ </div> <button {{perms.restore.disabled}} class="btn btn-primary pull-right" type="submit"> <span class="glyphicon glyphicon-open"></span> + {{id_prefix}} {{lang_restoreButton}} - {{#id_prefix}} – {{.}}{{/id_prefix}} </button> </div> </div> @@ -82,9 +82,17 @@ <div class="panel-heading">{{lang_autoBackupHeading}}</div> <div class="panel-body {{perms.config.disabled}}"> <p>{{lang_autoBackupText}}</p> - <div class="checkbox"> - <input id="auto-backup-enabled" type="checkbox" name="auto-backup-enabled" value="1" {{autoBackupEnabled_checked}}> - <label for="auto-backup-enabled">{{lang_autoBackupEnabled}}</label> + <div class="radio"> + <input id="auto-backup-OFF" type="radio" name="auto-backup-mode" value="OFF" {{backup_OFF_checked}}> + <label for="auto-backup-OFF">{{lang_autoBackupOFF}}</label> + </div> + <div class="radio"> + <input id="auto-backup-ROOTHOME" type="radio" name="auto-backup-mode" value="ROOTHOME" {{backup_ROOTHOME_checked}}> + <label for="auto-backup-ROOTHOME">{{lang_autoBackupROOTHOME}}</label> + </div> + <div class="radio"> + <input id="auto-backup-VMSTORE" type="radio" name="auto-backup-mode" value="VMSTORE" {{backup_VMSTORE_checked}}> + <label for="auto-backup-VMSTORE">{{lang_autoBackupVMSTORE}}</label> </div> <div class="form-group"> <label for="passwd-auto">{{lang_autoBackupPasswordLabel}}</label> |