backups: add mount configuration and status

This commit is contained in:
Girish Ramakrishnan
2021-05-17 15:24:19 -07:00
parent a3ea2a32f1
commit a54a404dac
2 changed files with 74 additions and 17 deletions
+38 -10
View File
@@ -130,11 +130,41 @@
<p class="has-error">{{ 'backups.configureBackupStorage.noopNote' | tr }}</p>
</div>
<!-- SSHFS/CIFS/NFS -->
<!-- SSHFS/CIFS/NFS/mountpoint/ext4 -->
<div class="form-group" ng-class="{ 'has-error': configureBackup.error.mountPoint || (configureBackupForm.mountPoint.$dirty && !configureBackup.mountPoint) }" ng-show="mountlike(configureBackup.provider)">
<label class="control-label" for="inputConfigureMountPoint">{{ 'backups.configureBackupStorage.mountPoint' | tr }}</label>
<input type="text" class="form-control" ng-model="configureBackup.mountPoint" id="inputConfigureMountPoint" name="mountPoint" ng-disabled="configureBackup.busy" placeholder="Folder where filesystem is mounted" ng-required="mountlike(configureBackup.provider)">
<p ng-bind-html="'backups.configureBackupStorage.mountPointDescription' | tr:{ providerDocsLink: 'https://docs.cloudron.io/backups/#'+configureBackup.provider }"></p>
<p ng-show="configureBackup.provider === 'mointpoint'" ng-bind-html="'backups.configureBackupStorage.mountPointDescription' | tr:{ providerDocsLink: 'https://docs.cloudron.io/backups/#'+configureBackup.provider }"></p>
</div>
<!-- CIFS/NFS -->
<div class="form-group" ng-show="configureBackup.provider === 'cifs' || configureBackup.provider === 'nfs'">
<label class="control-label" for="configureBackupHost">{{ 'backups.configureBackupStorage.server' | tr }} ({{ configureBackup.provider }})</label>
<input type="text" class="form-control" ng-model="configureBackup.mountOptions.host" id="configureBackupHost" name="host" ng-disabled="configureBackup.busy" placeholder="Server IP or hostname" ng-required="configureBackup.provider === 'cifs' || configureBackup.provider === 'nfs'">
</div>
<!-- CIFS/NFS -->
<div class="form-group" ng-show="configureBackup.provider === 'cifs' || configureBackup.provider === 'nfs'">
<label class="control-label" for="configureBackupRemoteDir">{{ 'backups.configureBackupStorage.remoteDirectory' | tr }} ({{ configureBackup.provider }})</label>
<input type="text" class="form-control" ng-model="configureBackup.mountOptions.remoteDir" id="configureBackupRemoteDir" name="remoteDir" ng-disabled="configureBackup.busy" placeholder="/share" ng-required="configureBackup.provider === 'cifs' || configureBackup.provider === 'nfs'">
</div>
<!-- CIFS -->
<div class="form-group" ng-show="configureBackup.provider === 'cifs'">
<label class="control-label" for="configureBackupUsername">{{ 'backups.configureBackupStorage.username' | tr }} ({{ configureBackup.provider }})</label>
<input type="text" class="form-control" ng-model="configureBackup.mountOptions.username" id="configureBackupUsername" name="username" ng-disabled="configureBackup.busy">
</div>
<!-- CIFS -->
<div class="form-group" ng-show="configureBackup.provider === 'cifs'">
<label class="control-label" for="configureBackupPassword">{{ 'backups.configureBackupStorage.password' | tr }} ({{ configureBackup.provider }})</label>
<input type="password" class="form-control" ng-model="configureBackup.mountOptions.password" id="configureBackupPassword" name="password" ng-disabled="configureBackup.busy">
</div>
<!-- EXT4 -->
<div class="form-group" ng-class="{ 'has-error': configureBackup.error.diskPath || !configureBackup.diskPath }" ng-show="configureBackup.provider === 'ext4'">
<label class="control-label" for="inputConfigureDiskPath">{{ 'backups.configureBackupStorage.diskPath' | tr }}</label>
<input type="text" class="form-control" ng-model="configureBackup.mountOptions.diskPath" id="inputConfigureDiskPath" name="diskPath" ng-disabled="configureBackup.busy" placeholder="Directory for backups" ng-required="configureBackup.provider === 'ext4'">
</div>
<!-- Filesystem -->
@@ -143,13 +173,7 @@
<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'">
</div>
<div class="checkbox" ng-show="configureBackup.provider === 'filesystem'">
<label>
<input type="checkbox" ng-model="configureBackup.externalDisk">{{ 'backups.configureBackupStorage.ext4Label' | tr }}</input>
</label>
</div>
<!-- Filesystem/SSHFS/CIFS/NFS -->
<!-- Filesystem/SSHFS/CIFS/NFS/EXT4/mountpoint -->
<div class="checkbox" ng-show="configureBackup.provider === 'filesystem' || mountlike(configureBackup.provider)">
<label>
<input type="checkbox" ng-model="configureBackup.useHardlinks">{{ 'backups.configureBackupStorage.hardlinksLabel' | tr }}</input>
@@ -359,7 +383,11 @@
</div>
<div class="col-xs-6 text-right no-wrap">
<span ng-show="backupConfig.provider === 'filesystem'">{{ backupConfig.backupFolder }}</span>
<span ng-show="mountlike(backupConfig.provider)">{{ backupConfig.mountPoint + (backupConfig.prefix ? '/' : '') + backupConfig.prefix }}</span>
<span ng-show="mountlike(backupConfig.provider)">
<i class="fa fa-circle" ng-style="{ color: backupConfig.mountStatus.state === 'active' ? '#27CE65' : '#d9534f' }" ng-show="backupConfig.mountStatus" uib-tooltip="{{ backupConfig.mountStatus.message }}"></i>
{{ backupConfig.mountPoint + (backupConfig.prefix ? '/' : '') + backupConfig.prefix }}
</span>
<span ng-show="backupConfig.provider !== 's3' && backupConfig.provider !== 'minio' && (s3like(backupConfig.provider) || backupConfig.provider === 'gcs')">{{ backupConfig.bucket + (backupConfig.prefix ? '/' : '') + backupConfig.prefix }}</span>
<span ng-show="backupConfig.provider === 's3'">{{ backupConfig.region + ' ' + backupConfig.bucket + (backupConfig.prefix ? '/' : '') + backupConfig.prefix }}</span>
<span ng-show="backupConfig.provider === 'minio'">{{ backupConfig.endpoint + ' ' + backupConfig.bucket + (backupConfig.prefix ? '/' : '') + backupConfig.prefix }}</span>
+36 -7
View File
@@ -96,8 +96,10 @@ angular.module('Application').controller('BackupsController', ['$scope', '$locat
{ name: 'Backblaze B2 (S3 API)', value: 'backblaze-b2' },
{ name: 'CIFS Mount', value: 'cifs' },
{ name: 'DigitalOcean Spaces', value: 'digitalocean-spaces' },
{ name: 'EXT4 Disk', value: 'ext4' },
{ name: 'Exoscale SOS', value: 'exoscale-sos' },
{ name: 'Filesystem', value: 'filesystem' },
{ name: 'Filesystem (Mountpoint)', value: 'mountpoint' }, // legacy
{ name: 'Google Cloud Storage', value: 'gcs' },
{ name: 'IONOS (Profitbricks)', value: 'ionos-objectstorage' },
{ name: 'Linode Object Storage', value: 'linode-objectstorage' },
@@ -287,7 +289,7 @@ angular.module('Application').controller('BackupsController', ['$scope', '$locat
};
$scope.mountlike = function (provider) {
return provider === 'sshfs' || provider === 'cifs' || provider === 'nfs';
return provider === 'sshfs' || provider === 'cifs' || provider === 'nfs' || provider === 'mountpoint' || provider === 'ext4';
};
// https://stackoverflow.com/questions/3665115/how-to-create-a-file-in-memory-for-user-to-download-but-not-through-server#18197341
@@ -413,7 +415,6 @@ angular.module('Application').controller('BackupsController', ['$scope', '$locat
mountPoint: '',
acceptSelfSignedCerts: false,
useHardlinks: true,
externalDisk: false,
format: 'tgz',
password: '',
passwordRepeat: '',
@@ -427,6 +428,14 @@ angular.module('Application').controller('BackupsController', ['$scope', '$locat
downloadConcurrency: '',
syncConcurrency: '', // sort of similar to upload
mountOptions: {
host: '',
remoteDir: '',
username: '',
password: '',
diskPath: ''
},
clearProviderFields: function () {
$scope.configureBackup.bucket = '';
$scope.configureBackup.prefix = '';
@@ -440,7 +449,6 @@ angular.module('Application').controller('BackupsController', ['$scope', '$locat
$scope.configureBackup.mountPoint = '';
$scope.configureBackup.acceptSelfSignedCerts = false;
$scope.configureBackup.useHardlinks = true;
$scope.configureBackup.externalDisk = false;
$scope.configureBackup.memoryLimit = 400 * 1024 * 1024;
// scaleway only supports 1000 parts per object (https://www.scaleway.com/en/docs/s3-multipart-upload/)
@@ -448,6 +456,8 @@ angular.module('Application').controller('BackupsController', ['$scope', '$locat
$scope.configureBackup.downloadConcurrency = $scope.configureBackup.provider === 's3' ? 30 : 10;
$scope.configureBackup.syncConcurrency = $scope.configureBackup.provider === 's3' ? 20 : 10;
$scope.configureBackup.copyConcurrency = $scope.configureBackup.provider === 's3' ? 500 : 10;
$scope.configureBackup.mount = { host: '', remoteDir: '', username: '', password: '', diskPath: '' };
},
show: function () {
@@ -478,7 +488,6 @@ 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;
$scope.configureBackup.memoryLimit = $scope.backupConfig.memoryLimit;
@@ -498,6 +507,14 @@ angular.module('Application').controller('BackupsController', ['$scope', '$locat
$scope.configureBackup.uploadPartSizeTicks.push(j * 1024 * 1024);
}
var mountOptions = $scope.backupConfig.mountOptions || {};
$scope.configureBackup.mount = {
host: mountOptions.host || '',
remoteDir: mountOptions.remoteDir || '',
username: mountOptions.username || '',
password: mountOptions.password || '',
diskPath: mountOptions.diskPath || ''
};
$('#configureBackupModal').modal('show');
},
@@ -573,14 +590,26 @@ angular.module('Application').controller('BackupsController', ['$scope', '$locat
$scope.configureBackup.busy = false;
return;
}
} else if (backupConfig.provider === 'sshfs' || backupConfig.provider === 'cifs' || backupConfig.provider === 'nfs') {
} else if ($scope.mountlike(backupConfig.provider)) {
backupConfig.mountPoint = $scope.configureBackup.mountPoint;
backupConfig.prefix = $scope.configureBackup.prefix;
backupConfig.noHardlinks = !$scope.configureBackup.useHardlinks;
} else if (backupConfig.provider === 'filesystem') {
backupConfig.mountOptions = {};
if (backupConfig.provider === 'cifs' || backupConfig.provider === 'sshfs' || backupConfig.provider === 'nfs') {
backupConfig.mountOptions.host = $scope.configureBackup.mountOptions.host;
backupConfig.mountOptions.remoteDir = $scope.configureBackup.mountOptions.remoteDir;
if (backupConfig.provider === 'cifs') {
backupConfig.mountOptions.username = $scope.configureBackup.mountOptions.username;
backupConfig.mountOptions.password = $scope.configureBackup.mountOptions.password;
}
} else if (backupConfig.provider === 'ext4') {
backupConfig.mountOptions.diskPath = $scope.configureBackup.diskPath;
}
} else if (backupConfig.provider === 'filesystem' || backupConfig.provider === 'mountpoint') {
backupConfig.backupFolder = $scope.configureBackup.backupFolder;
backupConfig.noHardlinks = !$scope.configureBackup.useHardlinks;
backupConfig.externalDisk = $scope.configureBackup.externalDisk;
}
backupConfig.uploadPartSize = $scope.configureBackup.uploadPartSize;