diff --git a/src/backups.js b/src/backups.js index de4de7937..9331e9a19 100644 --- a/src/backups.js +++ b/src/backups.js @@ -683,10 +683,8 @@ function backupBoxAndApps(auditSource, callback) { apps.getAll(function (error, allApps) { if (error) return callback(new BackupsError(BackupsError.INTERNAL_ERROR, error)); - var processed = 0; - var step = 100/(allApps.length+1); - - progress.set(progress.BACKUP, Math.min(step * processed, 5), ''); + var processed = 1; + var step = 100/(allApps.length+2); async.mapSeries(allApps, function iterator(app, iteratorCallback) { progress.set(progress.BACKUP, step * processed, 'Backing up ' + (app.altDomain || config.appFqdn(app.location))); diff --git a/src/progress.js b/src/progress.js index 0252809ad..e4fe95bff 100644 --- a/src/progress.js +++ b/src/progress.js @@ -52,10 +52,6 @@ function clear(tag) { debug('clearing %s', tag); } -function get(tag) { - return progress[tag]; -} - function getAll() { return progress; } diff --git a/src/storage/s3.js b/src/storage/s3.js index 585a80538..fe2a6b687 100644 --- a/src/storage/s3.js +++ b/src/storage/s3.js @@ -29,6 +29,7 @@ var assert = require('assert'), mkdirp = require('mkdirp'), PassThrough = require('stream').PassThrough, path = require('path'), + progress = require('../progress.js'), S3BlockReadStream = require('s3-block-read-stream'), superagent = require('superagent'); @@ -203,6 +204,7 @@ function downloadDir(apiConfig, backupFilePath, destDir, callback) { listDir(apiConfig, backupFilePath, { batchSize: 1 }, function downloadFile(s3, content, iteratorCallback) { var relativePath = path.relative(backupFilePath, content.Key); + mkdirp(path.dirname(path.join(destDir, relativePath)), function (error) { if (error) return iteratorCallback(new BackupsError(BackupsError.EXTERNAL_ERROR, error.message)); @@ -240,6 +242,8 @@ function copy(apiConfig, oldFilePath, newFilePath, callback) { CopySource: path.join(apiConfig.bucket, content.Key) }; + progress.setDetail(progress.BACKUP, 'Copying ' + content.Key.slice(oldFilePath.length+1)); + s3.copyObject(copyParams, function (error) { if (error && error.code === 'NoSuchKey') return iteratorCallback(new BackupsError(BackupsError.NOT_FOUND, 'Old backup not found')); if (error) {