diff --git a/CHANGES b/CHANGES index 3be64a6f2..bede9a1d6 100644 --- a/CHANGES +++ b/CHANGES @@ -2072,3 +2072,5 @@ * Fix issue where the long mongodb database names where causing app indices of rocket.chat to overflow (> 127) * Do not resize swap if swap file exists. This means that users can now control how swap is allocated on their own. * SFTP: fix issue where parallel rebuilds would cause an error +* backups: make part size configurable + diff --git a/src/routes/settings.js b/src/routes/settings.js index 5ae4a60c3..2c91ac767 100644 --- a/src/routes/settings.js +++ b/src/routes/settings.js @@ -115,6 +115,11 @@ function setBackupConfig(req, res, next) { if (typeof req.body.deleteConcurrency !== 'number') return next(new HttpError(400, 'deleteConcurrency must be a positive integer')); if (req.body.deleteConcurrency < 1) return next(new HttpError(400, 'deleteConcurrency must be a positive integer')); } + if ('uploadPartSize' in req.body) { + if (typeof req.body.uploadPartSize !== 'number') return next(new HttpError(400, 'uploadPartSize must be a positive integer')); + if (req.body.uploadPartSize < 1) return next(new HttpError(400, 'uploadPartSize must be a positive integer')); + } + if ('memoryLimit' in req.body && typeof req.body.memoryLimit !== 'number') return next(new HttpError(400, 'memoryLimit must be a positive integer')); if (typeof req.body.format !== 'string') return next(new HttpError(400, 'format must be a string')); if ('acceptSelfSignedCerts' in req.body && typeof req.body.acceptSelfSignedCerts !== 'boolean') return next(new HttpError(400, 'format must be a boolean')); diff --git a/src/settings.js b/src/settings.js index 8da128923..0e8e4b782 100644 --- a/src/settings.js +++ b/src/settings.js @@ -446,7 +446,7 @@ function setBackupCredentials(credentials, callback) { if (error) return callback(error); // preserve these fields - const extra = _.pick(currentConfig, 'retentionPolicy', 'schedulePattern', 'copyConcurrency', 'syncConcurrency', 'memoryLimit', 'downloadConcurrency', 'deleteConcurrency'); + const extra = _.pick(currentConfig, 'retentionPolicy', 'schedulePattern', 'copyConcurrency', 'syncConcurrency', 'memoryLimit', 'downloadConcurrency', 'deleteConcurrency', 'uploadPartSize'); const backupConfig = _.extend({}, credentials, extra); diff --git a/src/storage/s3.js b/src/storage/s3.js index 978d03a60..40e408d22 100644 --- a/src/storage/s3.js +++ b/src/storage/s3.js @@ -121,7 +121,7 @@ function upload(apiConfig, backupFilePath, sourceStream, callback) { // s3.upload automatically does a multi-part upload. we set queueSize to 3 to reduce memory usage // uploader will buffer at most queueSize * partSize bytes into memory at any given time. // scaleway only supports 1000 parts per object (https://www.scaleway.com/en/docs/s3-multipart-upload/) - const partSize = apiConfig.provider === 'scaleway-objectstorage' ? 100 * 1024 * 1024 : 10 * 1024 * 1024; + const partSize = apiConfig.uploadPartSize || (apiConfig.provider === 'scaleway-objectstorage' ? 100 * 1024 * 1024 : 10 * 1024 * 1024); s3.upload(params, { partSize, queueSize: 3 }, function (error, data) { if (error) {