Make user confirm that they use an external disk
This commit is contained in:
@@ -152,6 +152,10 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
|
||||
Notification.error({ title: 'Cloudron Error', message: message });
|
||||
};
|
||||
|
||||
Client.prototype.clearNotifications = function () {
|
||||
Notification.clearAll();
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
Example usage with an action:
|
||||
@@ -162,10 +166,10 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
|
||||
Client.notify('title', 'message', true, actionScope);
|
||||
|
||||
*/
|
||||
Client.prototype.notify = function (title, message, persitent, type, actionScope) {
|
||||
Client.prototype.notify = function (title, message, persistent, type, actionScope) {
|
||||
var options = { title: title, message: message};
|
||||
|
||||
if (persitent) options.delay = 'never'; // any non Number means never timeout
|
||||
if (persistent) options.delay = 'never'; // any non Number means never timeout
|
||||
|
||||
if (actionScope) {
|
||||
if (typeof actionScope.action !== 'string') throw('an actionScope has to have an action url');
|
||||
|
||||
@@ -46,8 +46,10 @@
|
||||
<label class="control-label" for="inputConfigureBackupFolder">Local backup directory</label>
|
||||
<input type="text" class="form-control" ng-model="configureBackup.backupFolder" id="inputConfigureBackupFolder" name="backupFolder" ng-disabled="configureBackup.busy" placeholder="Directory for backups" ng-required="configureBackup.provider === 'filesystem'">
|
||||
|
||||
<p class="has-error" ng-show="configureBackup.provider === 'filesystem'">
|
||||
Please ensure that the backup directory is an external ext4 disk
|
||||
<p class="checkbox" ng-show="configureBackup.provider === 'filesystem'">
|
||||
<label>
|
||||
<input type="checkbox" ng-model="configureBackup.externalDisk" id="inputConfigureExternalDisk">Backup directory is an external EXT4 Disk</input>
|
||||
</label>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -147,6 +147,7 @@ angular.module('Application').controller('BackupsController', ['$scope', '$locat
|
||||
retentionSecs: 7 * 24 * 60 * 60,
|
||||
acceptSelfSignedCerts: false,
|
||||
useHardlinks: true,
|
||||
externalDisk: false,
|
||||
format: 'tgz',
|
||||
|
||||
clearForm: function () {
|
||||
@@ -163,6 +164,7 @@ angular.module('Application').controller('BackupsController', ['$scope', '$locat
|
||||
$scope.configureBackup.format = 'tgz';
|
||||
$scope.configureBackup.acceptSelfSignedCerts = false;
|
||||
$scope.configureBackup.useHardlinks = true;
|
||||
$scope.configureBackup.externalDisk = false;
|
||||
},
|
||||
|
||||
show: function () {
|
||||
@@ -190,6 +192,7 @@ angular.module('Application').controller('BackupsController', ['$scope', '$locat
|
||||
$scope.configureBackup.format = $scope.backupConfig.format;
|
||||
$scope.configureBackup.acceptSelfSignedCerts = !!$scope.backupConfig.acceptSelfSignedCerts;
|
||||
$scope.configureBackup.useHardlinks = !$scope.backupConfig.noHardlinks;
|
||||
$scope.configureBackup.externalDisk = !!$scope.backupConfig.externalDisk;
|
||||
|
||||
$('#configureBackupModal').modal('show');
|
||||
},
|
||||
@@ -249,6 +252,7 @@ angular.module('Application').controller('BackupsController', ['$scope', '$locat
|
||||
} else if (backupConfig.provider === 'filesystem') {
|
||||
backupConfig.backupFolder = $scope.configureBackup.backupFolder;
|
||||
backupConfig.noHardlinks = !$scope.configureBackup.useHardlinks;
|
||||
backupConfig.externalDisk = $scope.configureBackup.externalDisk;
|
||||
}
|
||||
|
||||
Client.setBackupConfig(backupConfig, function (error) {
|
||||
@@ -329,12 +333,17 @@ angular.module('Application').controller('BackupsController', ['$scope', '$locat
|
||||
|
||||
$scope.backupConfig = backupConfig;
|
||||
|
||||
// Check if a proper storage backend is configured. TODO: this check fails if /var/backups is actually external
|
||||
if (backupConfig.provider === 'filesystem' && backupConfig.backupFolder === '/var/backups') {
|
||||
var actionScope = $scope.$new(true);
|
||||
actionScope.action = '/#/settings';
|
||||
Client.clearNotifications();
|
||||
|
||||
Client.notify('Backup Configuration', 'Please setup an external backup storage to avoid data loss', false, 'info', actionScope);
|
||||
// Check if a proper storage backend is configured. TODO: this check fails if /var/backups is actually external
|
||||
if (backupConfig.provider === 'filesystem' && !backupConfig.externalDisk) {
|
||||
var actionScope = $scope.$new(true);
|
||||
actionScope.action = '/#/backups';
|
||||
|
||||
Client.notify('Backup Configuration',
|
||||
'Cloudron backups are currently on the same disk as the Cloudron server instance. This is dangerous and can lead to complete data loss if the disk fails.' +
|
||||
'Please setup an external backup storage (or use server snapshots) and confirm this in backup configuration',
|
||||
true /* persistent */, 'error', actionScope);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user