@cloudant/couchbackup 2.11.18-SNAPSHOT-427 → 2.11.18-SNAPSHOT-429
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/includes/parser.js +69 -70
- package/package.json +2 -2
package/includes/parser.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright © 2017,
|
|
1
|
+
// Copyright © 2017, 2026 IBM Corp. All rights reserved.
|
|
2
2
|
//
|
|
3
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -12,60 +12,84 @@
|
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
|
|
15
|
+
const { Command } = require('commander');
|
|
16
|
+
const path = require('path');
|
|
15
17
|
const cliutils = require('./cliutils.js');
|
|
16
18
|
const config = require('./config.js');
|
|
17
19
|
const error = require('./error.js');
|
|
18
|
-
const path = require('path');
|
|
19
20
|
const pkg = require('../package.json');
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
// Option CLI defaults
|
|
23
|
+
const defaults = config.cliDefaults();
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
const backupProgram = new Command()
|
|
26
|
+
.version(pkg.version)
|
|
27
|
+
.description('Backup a CouchDB/Cloudant database to a backup text file.')
|
|
28
|
+
.usage('[options...]')
|
|
29
|
+
.option('-a, --attachments',
|
|
30
|
+
cliutils.getUsage('*EXPERIMENTAL/UNSUPPORTED*: enable backup of attachments', defaults.attachments))
|
|
31
|
+
.option('-b, --buffer-size <n>',
|
|
32
|
+
cliutils.getUsage('number of documents fetched at once', defaults.bufferSize),
|
|
33
|
+
Number)
|
|
34
|
+
.option('-d, --db <db>',
|
|
35
|
+
cliutils.getUsage('name of the database to backup', defaults.db))
|
|
36
|
+
.option('-k, --iam-api-key <API key>',
|
|
37
|
+
cliutils.getUsage('IAM API key to access the Cloudant server'))
|
|
38
|
+
.option('-l, --log <file>',
|
|
39
|
+
cliutils.getUsage('file to store logging information during backup; invalid in "shallow" mode', 'a temporary file'),
|
|
40
|
+
path.normalize)
|
|
41
|
+
.option('-m, --mode <mode>',
|
|
42
|
+
cliutils.getUsage('"shallow" if only a superficial backup is done (ignoring conflicts and revision tokens), else "full" for complete backup', defaults.mode),
|
|
43
|
+
(mode) => { return mode.toLowerCase(); })
|
|
44
|
+
.option('-o, --output <file>',
|
|
45
|
+
cliutils.getUsage('file name to store the backup data', 'stdout'),
|
|
46
|
+
path.normalize)
|
|
47
|
+
.option('-p, --parallelism <n>',
|
|
48
|
+
cliutils.getUsage('number of HTTP requests to perform in parallel when performing a backup; ignored in "shallow" mode', defaults.parallelism),
|
|
49
|
+
Number)
|
|
50
|
+
.option('-q, --quiet',
|
|
51
|
+
cliutils.getUsage('suppress batch messages', defaults.quiet))
|
|
52
|
+
.option('-r, --resume',
|
|
53
|
+
cliutils.getUsage('continue a previous backup from its last known position; invalid in "shallow" mode', defaults.resume))
|
|
54
|
+
.option('-t, --request-timeout <n>',
|
|
55
|
+
cliutils.getUsage('milliseconds to wait for a response to a HTTP request before retrying the request', defaults.requestTimeout),
|
|
56
|
+
Number)
|
|
57
|
+
.option('-u, --url <url>',
|
|
58
|
+
cliutils.getUsage('URL of the CouchDB/Cloudant server', defaults.url));
|
|
59
|
+
|
|
60
|
+
const restoreProgram = new Command()
|
|
61
|
+
.version(pkg.version)
|
|
62
|
+
.description('Restore a CouchDB/Cloudant database from a backup text file.')
|
|
63
|
+
.usage('[options...]')
|
|
64
|
+
.option('-a, --attachments',
|
|
65
|
+
cliutils.getUsage('*EXPERIMENTAL/UNSUPPORTED*: enable restore of attachments', defaults.attachments))
|
|
66
|
+
.option('-b, --buffer-size <n>',
|
|
67
|
+
cliutils.getUsage('number of documents restored at once', defaults.bufferSize),
|
|
68
|
+
Number)
|
|
69
|
+
.option('-d, --db <db>',
|
|
70
|
+
cliutils.getUsage('name of the new, existing database to restore to', defaults.db))
|
|
71
|
+
.option('-k, --iam-api-key <API key>',
|
|
72
|
+
cliutils.getUsage('IAM API key to access the Cloudant server'))
|
|
73
|
+
.option('-p, --parallelism <n>',
|
|
74
|
+
cliutils.getUsage('number of HTTP requests to perform in parallel when restoring a backup', defaults.parallelism),
|
|
75
|
+
Number)
|
|
76
|
+
.option('-q, --quiet',
|
|
77
|
+
cliutils.getUsage('suppress batch messages', defaults.quiet))
|
|
78
|
+
.option('-t, --request-timeout <n>',
|
|
79
|
+
cliutils.getUsage('milliseconds to wait for a response to a HTTP request before retrying the request', defaults.requestTimeout),
|
|
80
|
+
Number)
|
|
81
|
+
.option('-u, --url <url>',
|
|
82
|
+
cliutils.getUsage('URL of the CouchDB/Cloudant server', defaults.url));
|
|
26
83
|
|
|
84
|
+
function parseBackupArgs() {
|
|
27
85
|
// Options set by environment variables
|
|
28
86
|
const envVarOptions = {};
|
|
29
87
|
config.applyEnvironmentVariables(envVarOptions);
|
|
30
88
|
|
|
31
|
-
|
|
32
|
-
.version(pkg.version)
|
|
33
|
-
.description('Backup a CouchDB/Cloudant database to a backup text file.')
|
|
34
|
-
.usage('[options...]')
|
|
35
|
-
.option('-a, --attachments',
|
|
36
|
-
cliutils.getUsage('*EXPERIMENTAL/UNSUPPORTED*: enable backup of attachments', defaults.attachments))
|
|
37
|
-
.option('-b, --buffer-size <n>',
|
|
38
|
-
cliutils.getUsage('number of documents fetched at once', defaults.bufferSize),
|
|
39
|
-
Number)
|
|
40
|
-
.option('-d, --db <db>',
|
|
41
|
-
cliutils.getUsage('name of the database to backup', defaults.db))
|
|
42
|
-
.option('-k, --iam-api-key <API key>',
|
|
43
|
-
cliutils.getUsage('IAM API key to access the Cloudant server'))
|
|
44
|
-
.option('-l, --log <file>',
|
|
45
|
-
cliutils.getUsage('file to store logging information during backup; invalid in "shallow" mode', 'a temporary file'),
|
|
46
|
-
path.normalize)
|
|
47
|
-
.option('-m, --mode <mode>',
|
|
48
|
-
cliutils.getUsage('"shallow" if only a superficial backup is done (ignoring conflicts and revision tokens), else "full" for complete backup', defaults.mode),
|
|
49
|
-
(mode) => { return mode.toLowerCase(); })
|
|
50
|
-
.option('-o, --output <file>',
|
|
51
|
-
cliutils.getUsage('file name to store the backup data', 'stdout'),
|
|
52
|
-
path.normalize)
|
|
53
|
-
.option('-p, --parallelism <n>',
|
|
54
|
-
cliutils.getUsage('number of HTTP requests to perform in parallel when performing a backup; ignored in "shallow" mode', defaults.parallelism),
|
|
55
|
-
Number)
|
|
56
|
-
.option('-q, --quiet',
|
|
57
|
-
cliutils.getUsage('suppress batch messages', defaults.quiet))
|
|
58
|
-
.option('-r, --resume',
|
|
59
|
-
cliutils.getUsage('continue a previous backup from its last known position; invalid in "shallow" mode', defaults.resume))
|
|
60
|
-
.option('-t, --request-timeout <n>',
|
|
61
|
-
cliutils.getUsage('milliseconds to wait for a response to a HTTP request before retrying the request', defaults.requestTimeout),
|
|
62
|
-
Number)
|
|
63
|
-
.option('-u, --url <url>',
|
|
64
|
-
cliutils.getUsage('URL of the CouchDB/Cloudant server', defaults.url))
|
|
65
|
-
.parse(process.argv);
|
|
89
|
+
backupProgram.parse(process.argv);
|
|
66
90
|
|
|
67
91
|
// Remove defaults that don't apply when using shallow mode
|
|
68
|
-
if (
|
|
92
|
+
if (backupProgram.opts().mode === 'shallow' || envVarOptions.mode === 'shallow') {
|
|
69
93
|
delete defaults.parallelism;
|
|
70
94
|
delete defaults.log;
|
|
71
95
|
delete defaults.resume;
|
|
@@ -73,7 +97,7 @@ function parseBackupArgs() {
|
|
|
73
97
|
|
|
74
98
|
// Apply the options in order so that the CLI overrides env vars and env variables
|
|
75
99
|
// override defaults.
|
|
76
|
-
const opts = Object.assign({}, defaults, envVarOptions,
|
|
100
|
+
const opts = Object.assign({}, defaults, envVarOptions, backupProgram.opts());
|
|
77
101
|
|
|
78
102
|
if (opts.resume && (opts.log === defaults.log)) {
|
|
79
103
|
// If resuming and the log file arg is the newly generated tmp name from defaults then we know that --log wasn't specified.
|
|
@@ -84,8 +108,6 @@ function parseBackupArgs() {
|
|
|
84
108
|
}
|
|
85
109
|
|
|
86
110
|
function parseRestoreArgs() {
|
|
87
|
-
const { program } = require('commander');
|
|
88
|
-
|
|
89
111
|
// Option CLI defaults
|
|
90
112
|
const defaults = config.cliDefaults();
|
|
91
113
|
|
|
@@ -93,34 +115,11 @@ function parseRestoreArgs() {
|
|
|
93
115
|
const envVarOptions = {};
|
|
94
116
|
config.applyEnvironmentVariables(envVarOptions);
|
|
95
117
|
|
|
96
|
-
|
|
97
|
-
.version(pkg.version)
|
|
98
|
-
.description('Restore a CouchDB/Cloudant database from a backup text file.')
|
|
99
|
-
.usage('[options...]')
|
|
100
|
-
.option('-a, --attachments',
|
|
101
|
-
cliutils.getUsage('*EXPERIMENTAL/UNSUPPORTED*: enable restore of attachments', defaults.attachments))
|
|
102
|
-
.option('-b, --buffer-size <n>',
|
|
103
|
-
cliutils.getUsage('number of documents restored at once', defaults.bufferSize),
|
|
104
|
-
Number)
|
|
105
|
-
.option('-d, --db <db>',
|
|
106
|
-
cliutils.getUsage('name of the new, existing database to restore to', defaults.db))
|
|
107
|
-
.option('-k, --iam-api-key <API key>',
|
|
108
|
-
cliutils.getUsage('IAM API key to access the Cloudant server'))
|
|
109
|
-
.option('-p, --parallelism <n>',
|
|
110
|
-
cliutils.getUsage('number of HTTP requests to perform in parallel when restoring a backup', defaults.parallelism),
|
|
111
|
-
Number)
|
|
112
|
-
.option('-q, --quiet',
|
|
113
|
-
cliutils.getUsage('suppress batch messages', defaults.quiet))
|
|
114
|
-
.option('-t, --request-timeout <n>',
|
|
115
|
-
cliutils.getUsage('milliseconds to wait for a response to a HTTP request before retrying the request', defaults.requestTimeout),
|
|
116
|
-
Number)
|
|
117
|
-
.option('-u, --url <url>',
|
|
118
|
-
cliutils.getUsage('URL of the CouchDB/Cloudant server', defaults.url))
|
|
119
|
-
.parse(process.argv);
|
|
118
|
+
restoreProgram.parse(process.argv);
|
|
120
119
|
|
|
121
120
|
// Apply the options in order so that the CLI overrides env vars and env variables
|
|
122
121
|
// override defaults.
|
|
123
|
-
const opts = Object.assign({}, defaults, envVarOptions,
|
|
122
|
+
const opts = Object.assign({}, defaults, envVarOptions, restoreProgram.opts());
|
|
124
123
|
|
|
125
124
|
return opts;
|
|
126
125
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudant/couchbackup",
|
|
3
|
-
"version": "2.11.18-SNAPSHOT-
|
|
3
|
+
"version": "2.11.18-SNAPSHOT-429",
|
|
4
4
|
"description": "CouchBackup - command-line backup utility for Cloudant/CouchDB",
|
|
5
5
|
"homepage": "https://github.com/IBM/couchbackup",
|
|
6
6
|
"repository": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"eslint-plugin-header": "3.1.1",
|
|
42
42
|
"eslint-plugin-import": "2.32.0",
|
|
43
43
|
"http-proxy": "1.18.1",
|
|
44
|
-
"mocha": "11.7.
|
|
44
|
+
"mocha": "11.7.6",
|
|
45
45
|
"neostandard": "0.13.0",
|
|
46
46
|
"nock": "13.5.6",
|
|
47
47
|
"tail": "2.2.6",
|