From e3897c4c3427e17f9d3d0a022e85f2f2928cdf48 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Thu, 7 Jun 2018 11:19:43 -0700 Subject: [PATCH] Make user confirm that they use an external disk --- src/js/client.js | 8 ++++++-- src/views/backups.html | 6 ++++-- src/views/backups.js | 19 ++++++++++++++----- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/js/client.js b/src/js/client.js index 4608997ea..dfbbda707 100644 --- a/src/js/client.js +++ b/src/js/client.js @@ -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'); diff --git a/src/views/backups.html b/src/views/backups.html index 2289dcc59..e8366afe9 100644 --- a/src/views/backups.html +++ b/src/views/backups.html @@ -46,8 +46,10 @@ -

- Please ensure that the backup directory is an external ext4 disk +

+

diff --git a/src/views/backups.js b/src/views/backups.js index cba1c5561..988e2c5fa 100644 --- a/src/views/backups.js +++ b/src/views/backups.js @@ -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); } }); }