merge backupdb into backups.js
This commit is contained in:
53
src/storage.js
Normal file
53
src/storage.js
Normal file
@@ -0,0 +1,53 @@
|
||||
'use strict';
|
||||
|
||||
exports = module.exports = {
|
||||
api,
|
||||
|
||||
getBackupFilePath,
|
||||
};
|
||||
|
||||
const assert = require('assert'),
|
||||
path = require('path');
|
||||
|
||||
// choose which storage backend we use for test purpose we use s3
|
||||
function api(provider) {
|
||||
switch (provider) {
|
||||
case 'nfs': return require('./storage/filesystem.js');
|
||||
case 'cifs': return require('./storage/filesystem.js');
|
||||
case 'sshfs': return require('./storage/filesystem.js');
|
||||
case 'mountpoint': return require('./storage/filesystem.js');
|
||||
case 'ext4': return require('./storage/filesystem.js');
|
||||
case 's3': return require('./storage/s3.js');
|
||||
case 'gcs': return require('./storage/gcs.js');
|
||||
case 'filesystem': return require('./storage/filesystem.js');
|
||||
case 'minio': return require('./storage/s3.js');
|
||||
case 's3-v4-compat': return require('./storage/s3.js');
|
||||
case 'digitalocean-spaces': return require('./storage/s3.js');
|
||||
case 'exoscale-sos': return require('./storage/s3.js');
|
||||
case 'wasabi': return require('./storage/s3.js');
|
||||
case 'scaleway-objectstorage': return require('./storage/s3.js');
|
||||
case 'backblaze-b2': return require('./storage/s3.js');
|
||||
case 'linode-objectstorage': return require('./storage/s3.js');
|
||||
case 'ovh-objectstorage': return require('./storage/s3.js');
|
||||
case 'ionos-objectstorage': return require('./storage/s3.js');
|
||||
case 'vultr-objectstorage': return require('./storage/s3.js');
|
||||
case 'noop': return require('./storage/noop.js');
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
// This is not part of the storage api, since we don't want to pull the "format" logistics into that
|
||||
function getBackupFilePath(backupConfig, backupId, format) {
|
||||
assert.strictEqual(typeof backupConfig, 'object');
|
||||
assert.strictEqual(typeof backupId, 'string');
|
||||
assert.strictEqual(typeof format, 'string');
|
||||
|
||||
const backupPath = api(backupConfig.provider).getBackupPath(backupConfig);
|
||||
|
||||
if (format === 'tgz') {
|
||||
const fileType = backupConfig.encryption ? '.tar.gz.enc' : '.tar.gz';
|
||||
return path.join(backupPath, backupId+fileType);
|
||||
} else {
|
||||
return path.join(backupPath, backupId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user