1 | #!/usr/bin/env node
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | 'use strict';
|
16 |
|
17 | const error = require('../includes/error.js');
|
18 | const cliutils = require('../includes/cliutils.js');
|
19 | const couchbackup = require('../app.js');
|
20 | const parser = require('../includes/parser.js');
|
21 | const debug = require('debug')('couchbackup:restore');
|
22 | debug.enabled = true;
|
23 |
|
24 | var program = parser.parseRestoreArgs();
|
25 | var databaseUrl = cliutils.databaseUrl(program.url, program.db);
|
26 | var opts = {
|
27 | bufferSize: program.bufferSize,
|
28 | parallelism: program.parallelism,
|
29 | requestTimeout: program.requestTimeout,
|
30 | iamApiKey: program.iamApiKey,
|
31 | iamTokenUrl: program.iamTokenUrl
|
32 | };
|
33 |
|
34 |
|
35 | console.error('='.repeat(80));
|
36 | console.error('Performing restore on ' + databaseUrl.replace(/\/\/.+@/g, '//****:****@') + ' using configuration:');
|
37 | console.error(JSON.stringify(opts, null, 2).replace(/"iamApiKey": "[^"]+"/, '"iamApiKey": "****"'));
|
38 | console.error('='.repeat(80));
|
39 |
|
40 | return couchbackup.restore(
|
41 | process.stdin,
|
42 | databaseUrl,
|
43 | opts,
|
44 | error.terminationCallback
|
45 | ).on('restored', function(obj) {
|
46 | debug('restored', obj.total);
|
47 | }).on('error', function(e) {
|
48 | debug('ERROR', e);
|
49 | }).on('finished', function(obj) {
|
50 | debug('finished', obj);
|
51 | });
|