Only set backup storage options based on provider
This commit is contained in:
@@ -67,26 +67,96 @@ async function onSubmit() {
|
||||
const data = {
|
||||
provider: provider.value,
|
||||
format: format.value,
|
||||
prefix: prefix.value,
|
||||
noHardlinks: !useHardlinks.value,
|
||||
backupFolder: backupFolder.value,
|
||||
encryptedFilenames: encryptedFilenames.value,
|
||||
password: encryptionPassword.value,
|
||||
mountOptions: {
|
||||
hostPath: mountOptionHost.value,
|
||||
username: mountOptionUsername.value,
|
||||
password: mountOptionPassword.value,
|
||||
remoteDir: mountOptionRemoteDir.value,
|
||||
seal: mountOptionSeal.value,
|
||||
user: mountOptionUser.value,
|
||||
privateKey: mountOptionPrivateKey.value,
|
||||
},
|
||||
preserveAttributes: preserveAttributes.value,
|
||||
chown: chown.value,
|
||||
disk: disk.value,
|
||||
mountPoint: mountPoint.value,
|
||||
};
|
||||
|
||||
// required for api call to provide all fields
|
||||
data.chedulePattern = config.value.schedulePattern;
|
||||
data.etentionPolicy = config.value.retentionPolicy;
|
||||
|
||||
if (encryptionPassword.value) {
|
||||
data.encryptedFilenames = encryptedFilenames.value;
|
||||
data.password = encryptionPassword.value;
|
||||
}
|
||||
|
||||
if (s3like(data.provider)) {
|
||||
data.endpoint = endpoint.value;
|
||||
|
||||
if (data.provider === 's3') {
|
||||
data.region = region.value || undefined;
|
||||
delete data.endpoint;
|
||||
} else if (data.provider === 'minio' || data.provider === 's3-v4-compat') {
|
||||
data.region = region.value || 'us-east-1';
|
||||
data.acceptSelfSignedCerts = acceptSelfSignedCerts.value;
|
||||
data.s3ForcePathStyle = true;
|
||||
} else if (data.provider === 'exoscale-sos') {
|
||||
data.region = 'us-east-1';
|
||||
data.signatureVersion = 'v4';
|
||||
} else if (data.provider === 'wasabi') {
|
||||
data.region = REGIONS_WASABI.find(function (x) { return x.value === data.endpoint; }).region;
|
||||
data.signatureVersion = 'v4';
|
||||
} else if (data.provider === 'scaleway-objectstorage') {
|
||||
data.region = REGIONS_SCALEWAY.find(function (x) { return x.value === data.endpoint; }).region;
|
||||
data.signatureVersion = 'v4';
|
||||
} else if (data.provider === 'linode-objectstorage') {
|
||||
data.region = REGIONS_LINODE.find(function (x) { return x.value === data.endpoint; }).region;
|
||||
data.signatureVersion = 'v4';
|
||||
} else if (data.provider === 'ovh-objectstorage') {
|
||||
data.region = REGIONS_OVH.find(function (x) { return x.value === data.endpoint; }).region;
|
||||
data.signatureVersion = 'v4';
|
||||
} else if (data.provider === 'ionos-objectstorage') {
|
||||
data.region = REGIONS_IONOS.find(function (x) { return x.value === data.endpoint; }).region;
|
||||
data.signatureVersion = 'v4';
|
||||
} else if (data.provider === 'vultr-objectstorage') {
|
||||
data.region = REGIONS_VULTR.find(function (x) { return x.value === data.endpoint; }).region;
|
||||
data.signatureVersion = 'v4';
|
||||
} else if (data.provider === 'contabo-objectstorage') {
|
||||
data.region = REGIONS_CONTABO.find(function (x) { return x.value === data.endpoint; }).region;
|
||||
data.signatureVersion = 'v4';
|
||||
data.s3ForcePathStyle = true;
|
||||
} else if (data.provider === 'upcloud-objectstorage') { // the UI sets region and endpoint
|
||||
const m = /^.*\.(.*)\.upcloudobjects.com$/.exec(data.endpoint);
|
||||
data.region = m ? m[1] : 'us-east-1'; // let it fail in validation phase if m is not valid
|
||||
data.signatureVersion = 'v4';
|
||||
} else if (data.provider === 'digitalocean-spaces') {
|
||||
data.region = 'us-east-1';
|
||||
} else if (data.provider === 'hetzner-objectstorage') {
|
||||
data.region = 'us-east-1';
|
||||
data.signatureVersion = 'v4';
|
||||
}
|
||||
} else if (mountlike(data.provider)) {
|
||||
data.prefix = prefix.value;
|
||||
data.noHardlinks = !useHardlinks.value;
|
||||
data.mountOptions = {};
|
||||
|
||||
if (data.provider === 'cifs' || data.provider === 'sshfs' || data.provider === 'nfs') {
|
||||
data.mountOptions.host = mountOptionHost.value;
|
||||
data.mountOptions.remoteDir = mountOptionRemoteDir.value;
|
||||
|
||||
if (data.provider === 'cifs') {
|
||||
data.mountOptions.username = mountOptionUsername.value;
|
||||
data.mountOptions.password = mountOptionPassword.value;
|
||||
data.mountOptions.seal = !!mountOptionSeal.value;
|
||||
data.preserveAttributes = !!preserveAttributes.value;
|
||||
} else if (data.provider === 'sshfs') {
|
||||
data.mountOptions.user = mountOptionUser.value;
|
||||
data.mountOptions.port = parseInt(mountOptionPort.value);
|
||||
data.mountOptions.privateKey = mountOptionPrivateKey.value;
|
||||
data.preserveAttributes = true;
|
||||
}
|
||||
} else if (data.provider === 'ext4' || data.provider === 'xfs' || data.provider === 'disk') {
|
||||
data.mountOptions.diskPath = mountOptionDiskPath.value;
|
||||
data.preserveAttributes = true;
|
||||
} else if (data.provider === 'mountpoint') {
|
||||
data.mountPoint = mountPoint.value;
|
||||
data.chown = !!chown.value;
|
||||
data.preserveAttributes = !!preserveAttributes.value;
|
||||
}
|
||||
} else if (data.provider === 'filesystem') {
|
||||
data.backupFolder = backupFolder.value;
|
||||
data.noHardlinks = !useHardlinks.value;
|
||||
data.preserveAttributes = true;
|
||||
}
|
||||
|
||||
const limits = {
|
||||
memoryLimit: parseInt(memoryLimit.value),
|
||||
syncConcurrency: parseInt(syncConcurrency.value),
|
||||
|
||||
@@ -52,20 +52,17 @@ function create() {
|
||||
}
|
||||
|
||||
if (error || result.status !== 200) return [error || result];
|
||||
|
||||
// ensure we have objects
|
||||
if (!result.body.mountOptions) result.body.mountOptions = {};
|
||||
if (!result.body.limits) result.body.limits = {};
|
||||
|
||||
return [null, result.body];
|
||||
},
|
||||
async setConfig(config, limits) {
|
||||
const data = Object.assign(config);
|
||||
|
||||
// some s3 provider need signatureVersion
|
||||
const s3SignatureVersionV4Provider = ['exoscale-sos', 'wasabi', 'scaleway-objectstorage', 'linode-objectstorage', 'ovh-objectstorage', 'ionos-objectstorage', 'vultr-objectstorage', 'contabo-objectstorage', 'upcloud-objectstorage', 'hetzner-objectstorage'];
|
||||
if (s3SignatureVersionV4Provider.indefOf(data.provider) !== -1) data.signatureVersion = 'v4';
|
||||
|
||||
if (data.provider === 'minio' || data.provider === 's3-v4-compat' || data.provider === 'contabo-objectstorage') data.s3ForcePathStyle = true;
|
||||
|
||||
let error, result;
|
||||
try {
|
||||
result = await fetcher.post(`${origin}/api/v1/backups/config/storage`, data, { access_token: accessToken });
|
||||
result = await fetcher.post(`${origin}/api/v1/backups/config/storage`, config, { access_token: accessToken });
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user