backups: remove noop backend

the noop backend is migrated into 0 sites config.

when the updater code sees that there is no site to backup, it will
just fail. user has to manually update with skipBackup flag.
This commit is contained in:
Girish Ramakrishnan
2025-09-22 16:33:51 +02:00
parent 807094c829
commit 305441ea28
18 changed files with 17 additions and 246 deletions

View File

@@ -19,12 +19,9 @@ function api(format) {
throw new BoxError(BoxError.INTERNAL_ERROR, `Undefined format ${format}`);
}
function validateFormat(provider, format) {
assert.strictEqual(typeof provider, 'string');
function validateFormat(format) {
assert.strictEqual(typeof format, 'string');
if (provider === 'noop') return null;
if (format === 'tgz' || format == 'rsync') return null;
return new BoxError(BoxError.BAD_FIELD, 'Invalid backup format');

View File

@@ -93,7 +93,6 @@ function storageApi(backupSite) {
case 'upcloud-objectstorage': return require('./storage/s3.js');
case 'contabo-objectstorage': return require('./storage/s3.js');
case 'hetzner-objectstorage': return require('./storage/s3.js');
case 'noop': return require('./storage/noop.js');
default: throw new BoxError(BoxError.BAD_FIELD, `Unknown provider: ${backupSite.provider}`);
}
}
@@ -517,7 +516,7 @@ async function add(data, auditSource) {
encryptedFilenames = data.encryptedFilenames || false,
encryptionPasswordHint = data.encryptionPasswordHint || null;
const formatError = backupFormats.validateFormat(provider, format);
const formatError = backupFormats.validateFormat(format);
if (formatError) throw formatError;
const nameError = validateName(name);
@@ -581,7 +580,7 @@ async function createPseudo(data) {
const encryptionPassword = data.encryptionPassword ?? null,
encryptedFilenames = !!data.encryptedFilenames;
const formatError = backupFormats.validateFormat(provider, format);
const formatError = backupFormats.validateFormat(format);
if (formatError) throw formatError;
let encryption = null;

View File

@@ -1,135 +0,0 @@
'use strict';
exports = module.exports = {
getAvailableSize,
getStatus,
upload,
exists,
download,
copy,
listDir,
remove,
removeDir,
setup,
teardown,
cleanup,
verifyConfig,
removePrivateFields,
injectPrivateFields
};
const assert = require('node:assert'),
BoxError = require('../boxerror.js'),
debug = require('debug')('box:storage/noop'),
fs = require('node:fs');
async function getAvailableSize(apiConfig) {
assert.strictEqual(typeof apiConfig, 'object');
return Number.POSITIVE_INFINITY;
}
async function getStatus(apiConfig) {
assert.strictEqual(typeof apiConfig, 'object');
return { state: 'active' };
}
async function upload(apiConfig, remotePath) {
assert.strictEqual(typeof apiConfig, 'object');
assert.strictEqual(typeof remotePath, 'string');
debug(`upload: ${remotePath}`);
const uploadStream = fs.createWriteStream('/dev/null');
return {
stream: uploadStream,
async finish() {}
};
}
async function exists(apiConfig, remotePath) {
assert.strictEqual(typeof apiConfig, 'object');
assert.strictEqual(typeof remotePath, 'string');
debug(`exists: ${remotePath}`);
return false;
}
async function download(apiConfig, remotePath) {
assert.strictEqual(typeof apiConfig, 'object');
assert.strictEqual(typeof remotePath, 'string');
debug('download: %s', remotePath);
throw new BoxError(BoxError.NOT_IMPLEMENTED, 'Cannot download from noop backend');
}
async function listDir(apiConfig, remotePath, batchSize, marker) {
assert.strictEqual(typeof apiConfig, 'object');
assert.strictEqual(typeof remotePath, 'string');
assert.strictEqual(typeof batchSize, 'number');
assert(typeof marker !== 'undefined');
return { entries: [], marker: null };
}
async function copy(apiConfig, fromRemotePath, toRemotePath, progressCallback) {
assert.strictEqual(typeof apiConfig, 'object');
assert.strictEqual(typeof fromRemotePath, 'string');
assert.strictEqual(typeof toRemotePath, 'string');
assert.strictEqual(typeof progressCallback, 'function');
debug(`copy: ${fromRemotePath} -> ${toRemotePath}`);
}
async function remove(apiConfig, filename) {
assert.strictEqual(typeof apiConfig, 'object');
assert.strictEqual(typeof filename, 'string');
debug(`remove: ${filename}`);
}
async function removeDir(apiConfig, remotePathPrefix, progressCallback) {
assert.strictEqual(typeof apiConfig, 'object');
assert.strictEqual(typeof remotePathPrefix, 'string');
assert.strictEqual(typeof progressCallback, 'function');
debug(`removeDir: ${remotePathPrefix}`);
}
async function cleanup(apiConfig, progressCallback) {
assert.strictEqual(typeof apiConfig, 'object');
assert.strictEqual(typeof progressCallback, 'function');
}
async function verifyConfig({ id, provider, config }) {
assert.strictEqual(typeof id, 'string');
assert.strictEqual(typeof provider, 'string');
assert.strictEqual(typeof config, 'object');
return {};
}
async function setup(apiConfig) {
assert.strictEqual(typeof apiConfig, 'object');
}
async function teardown(apiConfig) {
assert.strictEqual(typeof apiConfig, 'object');
}
function removePrivateFields(apiConfig) {
return apiConfig;
}
// eslint-disable-next-line no-unused-vars
function injectPrivateFields(newConfig, currentConfig) {
}

View File

@@ -15,7 +15,6 @@ const backupSites = require('../backupsites.js'),
filesystem = require('../storage/filesystem.js'),
fs = require('node:fs'),
gcs = require('../storage/gcs.js'),
noop = require('../storage/noop.js'),
os = require('node:os'),
path = require('node:path'),
s3 = require('../storage/s3.js'),
@@ -150,40 +149,6 @@ describe('Storage', function () {
});
});
describe('noop', function () {
const gBackupConfig = {
provider: 'noop',
format: 'tgz'
};
it('upload works', async function () {
await noop.upload(gBackupConfig, 'file', {});
});
it('can download file', async function () {
const [error] = await safe(noop.download(gBackupConfig, 'file'));
expect(error).to.be.an(Error);
});
it('list dir contents of source dir', async function () {
const result = await noop.listDir(gBackupConfig, 'sourceDir', 1000, null /* marker */);
expect(result.marker).to.be(null);
expect(result.entries).to.eql([]);
});
it('can copy', async function () {
await noop.copy(gBackupConfig, 'sourceFile', 'destFile', () => {});
});
it('can remove file', async function () {
await noop.remove(gBackupConfig, 'sourceFile');
});
it('can remove empty dir', async function () {
await noop.remove(gBackupConfig, 'sourceDir');
});
});
describe('s3', function () {
const basePath = path.join(os.tmpdir(), 's3-backup-test-buckets');
const backupConfig = {