nitor 1.5.0 → 1.7.0
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/CHANGELOG.md +37 -0
- package/LICENSE +15 -0
- package/README.md +21 -2
- package/package.json +13 -4
- package/services/autocomplete.js +8 -0
- package/services/enums/actions.enum.js +1 -0
- package/services/mr-status.js +306 -0
- package/services/process-commands.js +29 -3
- package/services/task-stats.js +22 -3
- package/services/utils.js +36 -9
- package/.commitlintrc.json +0 -10
- package/.editorconfig +0 -16
- package/.eslintrc.js +0 -29
- package/.gitattributes +0 -2
- package/.prettierrc +0 -5
- package/.releaserc.json +0 -34
- package/docs/AUTOCOMPLETE.md +0 -136
- package/docs/BACKUP.md +0 -343
- package/docs/BUILD.md +0 -120
- package/docs/BUILD_DEPLOY.md +0 -320
- package/docs/CLEANUP.md +0 -285
- package/docs/CREATE_BRANCH.md +0 -173
- package/docs/DEPLOY.md +0 -130
- package/docs/MERGE.md +0 -253
- package/docs/README.md +0 -277
- package/docs/REFACTOR.md +0 -375
- package/docs/REVIEW.md +0 -185
- package/docs/TIME_ENTRY.md +0 -422
package/services/utils.js
CHANGED
|
@@ -31,6 +31,8 @@ const zohoConfig = {
|
|
|
31
31
|
token: process.env.ZOHO_TOKEN,
|
|
32
32
|
url: process.env.ZOHO_URI,
|
|
33
33
|
userId: process.env.ZOHO_USERID,
|
|
34
|
+
workspace: process.env.ZOHO_WORKSPACE,
|
|
35
|
+
projectPrefix: process.env.ZOHO_PROJECT_PREFIX,
|
|
34
36
|
};
|
|
35
37
|
const keyMap = {
|
|
36
38
|
components: 'components',
|
|
@@ -61,6 +63,10 @@ const keyMap = {
|
|
|
61
63
|
do: 'docker',
|
|
62
64
|
sprint: 'sprint',
|
|
63
65
|
s: 'sprint',
|
|
66
|
+
state: 'state',
|
|
67
|
+
st: 'state',
|
|
68
|
+
search: 'search',
|
|
69
|
+
q: 'search',
|
|
64
70
|
};
|
|
65
71
|
const projectMap = {
|
|
66
72
|
portal: 'medica-portal',
|
|
@@ -388,6 +394,23 @@ const box = {
|
|
|
388
394
|
// Loading spinner frames
|
|
389
395
|
const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
390
396
|
|
|
397
|
+
// Match CSI (SGR etc.) and OSC 8 hyperlink escape sequences so we can compute
|
|
398
|
+
// the visible width of strings that contain ANSI styling or terminal links.
|
|
399
|
+
// eslint-disable-next-line no-control-regex
|
|
400
|
+
const ANSI_REGEX = /\x1B\]8;[^\x07\x1B]*(?:\x07|\x1B\\)|\x1B\[[0-9;]*[A-Za-z]/g;
|
|
401
|
+
const stripAnsi = (s) => String(s ?? '').replace(ANSI_REGEX, '');
|
|
402
|
+
const visibleLength = (s) => stripAnsi(s).length;
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Wrap text in an OSC 8 terminal hyperlink so supporting terminals render it
|
|
406
|
+
* as a clickable link.
|
|
407
|
+
*/
|
|
408
|
+
const makeLink = (url, text = url) => {
|
|
409
|
+
if (!url) return String(text ?? '');
|
|
410
|
+
|
|
411
|
+
return `\x1B]8;;${url}\x07${text}\x1B]8;;\x07`;
|
|
412
|
+
};
|
|
413
|
+
|
|
391
414
|
/**
|
|
392
415
|
* Create a loading spinner for async operations
|
|
393
416
|
* @param {string} message - Loading message to display
|
|
@@ -491,24 +514,27 @@ const printTable = (data, options = {}) => {
|
|
|
491
514
|
});
|
|
492
515
|
}
|
|
493
516
|
|
|
494
|
-
// Calculate column widths
|
|
517
|
+
// Calculate column widths (ignore ANSI/hyperlink escapes when measuring)
|
|
495
518
|
const colWidths = {};
|
|
496
519
|
columns.forEach((col) => {
|
|
497
520
|
const headerLen = col.length;
|
|
498
|
-
const maxDataLen = Math.max(
|
|
499
|
-
...filteredData.map((row) => String(row[col] ?? '').length),
|
|
500
|
-
headerLen,
|
|
501
|
-
);
|
|
521
|
+
const maxDataLen = Math.max(...filteredData.map((row) => visibleLength(row[col])), headerLen);
|
|
502
522
|
colWidths[col] = Math.min(maxDataLen, maxColWidth);
|
|
503
523
|
});
|
|
504
524
|
|
|
505
|
-
// Helper to truncate and pad text
|
|
525
|
+
// Helper to truncate and pad text while preserving ANSI/hyperlink escapes
|
|
506
526
|
const formatCell = (text, width) => {
|
|
507
527
|
const str = String(text ?? '');
|
|
508
|
-
|
|
509
|
-
|
|
528
|
+
const visible = visibleLength(str);
|
|
529
|
+
|
|
530
|
+
if (visible > width) {
|
|
531
|
+
// Only values without embedded escapes are safely truncatable; for
|
|
532
|
+
// links/colored values, fall back to stripped text to keep widths sane.
|
|
533
|
+
const plain = stripAnsi(str);
|
|
534
|
+
return plain.substring(0, width - 2) + '..';
|
|
510
535
|
}
|
|
511
|
-
|
|
536
|
+
|
|
537
|
+
return str + ' '.repeat(width - visible);
|
|
512
538
|
};
|
|
513
539
|
|
|
514
540
|
// Top border
|
|
@@ -623,4 +649,5 @@ module.exports = {
|
|
|
623
649
|
gitlabConfig,
|
|
624
650
|
printTable,
|
|
625
651
|
createSpinner,
|
|
652
|
+
makeLink,
|
|
626
653
|
};
|
package/.commitlintrc.json
DELETED
package/.editorconfig
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# Editor configuration, see https://editorconfig.org
|
|
2
|
-
root = true
|
|
3
|
-
|
|
4
|
-
[*]
|
|
5
|
-
charset = utf-8
|
|
6
|
-
indent_style = space
|
|
7
|
-
indent_size = 2
|
|
8
|
-
insert_final_newline = true
|
|
9
|
-
trim_trailing_whitespace = true
|
|
10
|
-
|
|
11
|
-
[*.ts]
|
|
12
|
-
quote_type = single
|
|
13
|
-
|
|
14
|
-
[*.md]
|
|
15
|
-
max_line_length = off
|
|
16
|
-
trim_trailing_whitespace = false
|
package/.eslintrc.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
env: {
|
|
3
|
-
browser: true,
|
|
4
|
-
node: true,
|
|
5
|
-
commonjs: true,
|
|
6
|
-
},
|
|
7
|
-
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
|
|
8
|
-
overrides: [
|
|
9
|
-
{
|
|
10
|
-
env: {
|
|
11
|
-
node: true,
|
|
12
|
-
},
|
|
13
|
-
files: ['.eslintrc.{js,cjs}'],
|
|
14
|
-
parserOptions: {
|
|
15
|
-
sourceType: 'script',
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
],
|
|
19
|
-
parser: '@typescript-eslint/parser',
|
|
20
|
-
parserOptions: {
|
|
21
|
-
ecmaVersion: 'latest',
|
|
22
|
-
sourceType: 'module',
|
|
23
|
-
},
|
|
24
|
-
plugins: ['@typescript-eslint'],
|
|
25
|
-
rules: {
|
|
26
|
-
'@typescript-eslint/no-unsafe-optional-chain': 'off',
|
|
27
|
-
'@typescript-eslint/no-var-requires': 'off',
|
|
28
|
-
},
|
|
29
|
-
};
|
package/.gitattributes
DELETED
package/.prettierrc
DELETED
package/.releaserc.json
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"branches": ["master"],
|
|
3
|
-
"plugins": [
|
|
4
|
-
[
|
|
5
|
-
"@semantic-release/commit-analyzer",
|
|
6
|
-
{
|
|
7
|
-
"preset": "angular",
|
|
8
|
-
"releaseRules": [
|
|
9
|
-
{ "type": "feat", "release": "minor" },
|
|
10
|
-
{ "type": "fix", "release": "patch" },
|
|
11
|
-
{ "type": "docs", "release": false },
|
|
12
|
-
{ "type": "style", "release": false },
|
|
13
|
-
{ "type": "refactor", "release": "patch" },
|
|
14
|
-
{ "type": "perf", "release": "patch" },
|
|
15
|
-
{ "type": "breaking", "release": "major" }
|
|
16
|
-
],
|
|
17
|
-
"parserOpts": {
|
|
18
|
-
"noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES"]
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
],
|
|
22
|
-
"@semantic-release/release-notes-generator",
|
|
23
|
-
"@semantic-release/changelog",
|
|
24
|
-
"@semantic-release/npm",
|
|
25
|
-
"@semantic-release/github",
|
|
26
|
-
[
|
|
27
|
-
"@semantic-release/git",
|
|
28
|
-
{
|
|
29
|
-
"assets": ["CHANGELOG.md", "package.json"],
|
|
30
|
-
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
|
|
31
|
-
}
|
|
32
|
-
]
|
|
33
|
-
]
|
|
34
|
-
}
|
package/docs/AUTOCOMPLETE.md
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
# Autocomplete Setup Guide
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
Nitor supports shell autocomplete for commands, options, and values using the `omelette` library.
|
|
6
|
-
|
|
7
|
-
## Setup
|
|
8
|
-
|
|
9
|
-
### 1. Install Autocomplete
|
|
10
|
-
|
|
11
|
-
After installing nitor globally, run:
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
nitor completion
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
### 2. Activate Autocomplete
|
|
18
|
-
|
|
19
|
-
Restart your terminal or source your shell configuration:
|
|
20
|
-
|
|
21
|
-
**For Bash:**
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
source ~/.bashrc
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
**For Zsh:**
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
source ~/.zshrc
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
**For Fish:**
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
source ~/.config/fish/config.fish
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Usage
|
|
40
|
-
|
|
41
|
-
Once autocomplete is enabled, press `Tab` to see suggestions:
|
|
42
|
-
|
|
43
|
-
### Command Completion
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
nitor <Tab>
|
|
47
|
-
# Shows: build, deploy, build-deploy, create-branch, review, refactor, backup, merge, cleanup,
|
|
48
|
-
# time-init, time-switch, time-add, time-update, time-delete, time-stats, time-entries,
|
|
49
|
-
# time-zoho, time-gitlab, time-merge, version, help
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### Option Completion
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
nitor build -<Tab>
|
|
56
|
-
# Shows: -project, -p, -components, -c, -instance, -i, -help, --h
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### Value Completion
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
nitor build -project <Tab>
|
|
63
|
-
# Shows: portal, gateway, phr, configService, healthRecords, centralAuth, mpi, phrAdminBackend, phrAdminClient, terminologyService
|
|
64
|
-
|
|
65
|
-
nitor build -instance <Tab>
|
|
66
|
-
# Shows: dev, qa, pilot
|
|
67
|
-
|
|
68
|
-
nitor create-branch -type <Tab>
|
|
69
|
-
# Shows: feat, fix
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
## Supported Completions
|
|
73
|
-
|
|
74
|
-
### Commands
|
|
75
|
-
|
|
76
|
-
- `build`, `deploy`, `build-deploy`
|
|
77
|
-
- `create-branch`, `review`, `refactor`
|
|
78
|
-
- `backup`, `merge`, `cleanup`
|
|
79
|
-
- `time-init`, `time-switch`, `time-add`, `time-update`, `time-delete`
|
|
80
|
-
- `time-stats`, `time-entries`, `time-zoho`, `time-gitlab`, `time-merge`
|
|
81
|
-
- `version`, `help`, `completion`
|
|
82
|
-
|
|
83
|
-
### Options
|
|
84
|
-
|
|
85
|
-
- Project names: `portal`, `gateway`, `phr`, etc.
|
|
86
|
-
- Components: `client`, `administration`, `provider`, `rest-api`
|
|
87
|
-
- Instances: `dev`, `qa`, `pilot`
|
|
88
|
-
- Branch types: `feat`, `fix`
|
|
89
|
-
- Repository names: `portalClient`, `portalBackend`, etc.
|
|
90
|
-
|
|
91
|
-
## Troubleshooting
|
|
92
|
-
|
|
93
|
-
### Autocomplete Not Working
|
|
94
|
-
|
|
95
|
-
1. **Verify installation:**
|
|
96
|
-
|
|
97
|
-
```bash
|
|
98
|
-
nitor completion
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
2. **Check shell configuration:**
|
|
102
|
-
|
|
103
|
-
- Bash: `~/.bashrc`
|
|
104
|
-
- Zsh: `~/.zshrc`
|
|
105
|
-
- Fish: `~/.config/fish/config.fish`
|
|
106
|
-
|
|
107
|
-
3. **Reload shell:**
|
|
108
|
-
```bash
|
|
109
|
-
exec $SHELL
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### Manual Setup
|
|
113
|
-
|
|
114
|
-
If automatic setup doesn't work, add this to your shell configuration:
|
|
115
|
-
|
|
116
|
-
**Bash (~/.bashrc):**
|
|
117
|
-
|
|
118
|
-
```bash
|
|
119
|
-
# nitor autocomplete
|
|
120
|
-
if type nitor > /dev/null 2>&1; then
|
|
121
|
-
eval "$(nitor --completion)"
|
|
122
|
-
fi
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
**Zsh (~/.zshrc):**
|
|
126
|
-
|
|
127
|
-
```bash
|
|
128
|
-
# nitor autocomplete
|
|
129
|
-
if type nitor > /dev/null 2>&1; then
|
|
130
|
-
eval "$(nitor --completion)"
|
|
131
|
-
fi
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
## Uninstall Autocomplete
|
|
135
|
-
|
|
136
|
-
To remove autocomplete, edit your shell configuration file and remove the nitor completion lines, then reload your shell.
|
package/docs/BACKUP.md
DELETED
|
@@ -1,343 +0,0 @@
|
|
|
1
|
-
# Backup Command Guide
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
The `backup` command creates MongoDB database backups for specified projects and components, ensuring data safety and recovery options.
|
|
6
|
-
|
|
7
|
-
## Usage
|
|
8
|
-
|
|
9
|
-
### Basic Syntax
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
nitor backup -project <project name> -components <component name>
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
### Short Form
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
nitor backup -p <project name> -c <component name>
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Options
|
|
22
|
-
|
|
23
|
-
| Option | Short | Description | Required |
|
|
24
|
-
| -------------- | ------- | -------------- | -------- |
|
|
25
|
-
| `--project` | `-p` | Project name | Yes |
|
|
26
|
-
| `--components` | `-c` | Component name | Optional |
|
|
27
|
-
| `--help` | `-help` | Show help | - |
|
|
28
|
-
|
|
29
|
-
## Examples
|
|
30
|
-
|
|
31
|
-
### Backup Config Service
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
nitor backup -p configService
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
### Backup Medica Central Auth
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
nitor backup -project medicaCentralAuth
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
### Backup Medica Portal
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
nitor backup -p medicaPortal
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### Backup PHR System
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
nitor backup -project phr
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Supported Projects
|
|
56
|
-
|
|
57
|
-
- **configService** - Configuration service database
|
|
58
|
-
- **medicaCentralAuth** - Medica central authentication database
|
|
59
|
-
- **medicaPortal** - Medica portal database
|
|
60
|
-
- **phr** - Personal Health Records database
|
|
61
|
-
|
|
62
|
-
## Backup Process
|
|
63
|
-
|
|
64
|
-
The backup command will:
|
|
65
|
-
|
|
66
|
-
1. **Connect to MongoDB**
|
|
67
|
-
|
|
68
|
-
- Establishes connection to database server
|
|
69
|
-
- Authenticates with credentials
|
|
70
|
-
|
|
71
|
-
2. **Identify Databases**
|
|
72
|
-
|
|
73
|
-
- Determines which databases to backup
|
|
74
|
-
- Based on project and component parameters
|
|
75
|
-
|
|
76
|
-
3. **Create Backup**
|
|
77
|
-
|
|
78
|
-
- Exports database collections
|
|
79
|
-
- Preserves data structure and relationships
|
|
80
|
-
|
|
81
|
-
4. **Store Backup**
|
|
82
|
-
|
|
83
|
-
- Saves backup to designated location
|
|
84
|
-
- Includes timestamp in filename
|
|
85
|
-
|
|
86
|
-
5. **Verify Backup**
|
|
87
|
-
- Confirms backup completion
|
|
88
|
-
- Reports backup status
|
|
89
|
-
|
|
90
|
-
## Backup Location
|
|
91
|
-
|
|
92
|
-
Backups are typically stored in:
|
|
93
|
-
|
|
94
|
-
- Project-specific backup directory
|
|
95
|
-
- Timestamped folders for version control
|
|
96
|
-
- Compressed format for space efficiency
|
|
97
|
-
|
|
98
|
-
## Backup Naming Convention
|
|
99
|
-
|
|
100
|
-
Backups follow this pattern:
|
|
101
|
-
|
|
102
|
-
```
|
|
103
|
-
<project>_<component>_<timestamp>.backup
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
**Examples:**
|
|
107
|
-
|
|
108
|
-
- `configService_20241115_171030.backup`
|
|
109
|
-
- `medicaPortal_20241115_171030.backup`
|
|
110
|
-
- `phr_20241115_171030.backup`
|
|
111
|
-
|
|
112
|
-
## When to Backup
|
|
113
|
-
|
|
114
|
-
### Regular Backups
|
|
115
|
-
|
|
116
|
-
- **Daily** - For production databases
|
|
117
|
-
- **Before Deployments** - Prior to major changes
|
|
118
|
-
- **Before Migrations** - Before schema updates
|
|
119
|
-
- **Weekly** - For development databases
|
|
120
|
-
|
|
121
|
-
### Critical Moments
|
|
122
|
-
|
|
123
|
-
- Before major feature releases
|
|
124
|
-
- Before data migrations
|
|
125
|
-
- Before system upgrades
|
|
126
|
-
- After significant data changes
|
|
127
|
-
|
|
128
|
-
## Best Practices
|
|
129
|
-
|
|
130
|
-
### Backup Strategy
|
|
131
|
-
|
|
132
|
-
1. **Schedule Regular Backups**
|
|
133
|
-
|
|
134
|
-
- Automate daily backups
|
|
135
|
-
- Use cron jobs or schedulers
|
|
136
|
-
|
|
137
|
-
2. **Test Backups**
|
|
138
|
-
|
|
139
|
-
- Regularly verify backup integrity
|
|
140
|
-
- Practice restoration procedures
|
|
141
|
-
|
|
142
|
-
3. **Multiple Locations**
|
|
143
|
-
|
|
144
|
-
- Store backups in multiple locations
|
|
145
|
-
- Use cloud storage for redundancy
|
|
146
|
-
|
|
147
|
-
4. **Retention Policy**
|
|
148
|
-
- Keep daily backups for 7 days
|
|
149
|
-
- Keep weekly backups for 1 month
|
|
150
|
-
- Keep monthly backups for 1 year
|
|
151
|
-
|
|
152
|
-
### Security
|
|
153
|
-
|
|
154
|
-
1. **Encrypt Backups**
|
|
155
|
-
|
|
156
|
-
- Use encryption for sensitive data
|
|
157
|
-
- Secure backup storage locations
|
|
158
|
-
|
|
159
|
-
2. **Access Control**
|
|
160
|
-
|
|
161
|
-
- Limit backup access to authorized users
|
|
162
|
-
- Use strong authentication
|
|
163
|
-
|
|
164
|
-
3. **Audit Trail**
|
|
165
|
-
- Log backup operations
|
|
166
|
-
- Track who created backups
|
|
167
|
-
|
|
168
|
-
## Restoration
|
|
169
|
-
|
|
170
|
-
To restore from a backup:
|
|
171
|
-
|
|
172
|
-
1. **Locate Backup File**
|
|
173
|
-
|
|
174
|
-
```bash
|
|
175
|
-
ls -la /path/to/backups/
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
2. **Verify Backup Integrity**
|
|
179
|
-
|
|
180
|
-
- Check file size
|
|
181
|
-
- Verify timestamp
|
|
182
|
-
|
|
183
|
-
3. **Restore Database**
|
|
184
|
-
|
|
185
|
-
```bash
|
|
186
|
-
mongorestore --archive=<backup-file>
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
4. **Verify Restoration**
|
|
190
|
-
- Check data integrity
|
|
191
|
-
- Test application functionality
|
|
192
|
-
|
|
193
|
-
## Troubleshooting
|
|
194
|
-
|
|
195
|
-
### Backup Fails to Start
|
|
196
|
-
|
|
197
|
-
1. **Check MongoDB Connection:**
|
|
198
|
-
|
|
199
|
-
- Verify MongoDB is running
|
|
200
|
-
- Test connection credentials
|
|
201
|
-
- Check network connectivity
|
|
202
|
-
|
|
203
|
-
2. **Verify Permissions:**
|
|
204
|
-
|
|
205
|
-
- Ensure user has backup privileges
|
|
206
|
-
- Check file system permissions
|
|
207
|
-
|
|
208
|
-
3. **Check Disk Space:**
|
|
209
|
-
```bash
|
|
210
|
-
df -h
|
|
211
|
-
```
|
|
212
|
-
- Ensure sufficient space for backup
|
|
213
|
-
|
|
214
|
-
### Incomplete Backup
|
|
215
|
-
|
|
216
|
-
If backup completes but seems incomplete:
|
|
217
|
-
|
|
218
|
-
1. **Check Logs:**
|
|
219
|
-
|
|
220
|
-
- Review backup logs for errors
|
|
221
|
-
- Look for timeout issues
|
|
222
|
-
|
|
223
|
-
2. **Verify Collections:**
|
|
224
|
-
|
|
225
|
-
- List all collections
|
|
226
|
-
- Compare with backup contents
|
|
227
|
-
|
|
228
|
-
3. **Retry Backup:**
|
|
229
|
-
- Run backup again
|
|
230
|
-
- Use verbose mode for details
|
|
231
|
-
|
|
232
|
-
### Connection Errors
|
|
233
|
-
|
|
234
|
-
If you encounter connection errors:
|
|
235
|
-
|
|
236
|
-
1. **Verify MongoDB Status:**
|
|
237
|
-
|
|
238
|
-
```bash
|
|
239
|
-
systemctl status mongod
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
2. **Check Credentials:**
|
|
243
|
-
|
|
244
|
-
- Verify username and password
|
|
245
|
-
- Ensure user has proper roles
|
|
246
|
-
|
|
247
|
-
3. **Test Connection:**
|
|
248
|
-
```bash
|
|
249
|
-
mongo --host <host> --port <port>
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
## Configuration
|
|
253
|
-
|
|
254
|
-
The backup command requires:
|
|
255
|
-
|
|
256
|
-
1. **MongoDB Connection Details:**
|
|
257
|
-
|
|
258
|
-
- Host and port
|
|
259
|
-
- Database name
|
|
260
|
-
- Authentication credentials
|
|
261
|
-
|
|
262
|
-
2. **Backup Storage:**
|
|
263
|
-
|
|
264
|
-
- Backup directory path
|
|
265
|
-
- Sufficient disk space
|
|
266
|
-
- Write permissions
|
|
267
|
-
|
|
268
|
-
3. **Environment Variables:**
|
|
269
|
-
- MongoDB connection string
|
|
270
|
-
- Backup configuration
|
|
271
|
-
|
|
272
|
-
## Automation
|
|
273
|
-
|
|
274
|
-
### Cron Job Example
|
|
275
|
-
|
|
276
|
-
```bash
|
|
277
|
-
# Daily backup at 2 AM
|
|
278
|
-
0 2 * * * nitor backup -p configService
|
|
279
|
-
|
|
280
|
-
# Weekly backup on Sunday at 3 AM
|
|
281
|
-
0 3 * * 0 nitor backup -p medicaPortal
|
|
282
|
-
|
|
283
|
-
# Monthly backup on 1st at 4 AM
|
|
284
|
-
0 4 1 * * nitor backup -p phr
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
### Backup Script
|
|
288
|
-
|
|
289
|
-
```bash
|
|
290
|
-
#!/bin/bash
|
|
291
|
-
# Backup all projects
|
|
292
|
-
|
|
293
|
-
projects=("configService" "medicaCentralAuth" "medicaPortal" "phr")
|
|
294
|
-
|
|
295
|
-
for project in "${projects[@]}"; do
|
|
296
|
-
echo "Backing up $project..."
|
|
297
|
-
nitor backup -p "$project"
|
|
298
|
-
done
|
|
299
|
-
|
|
300
|
-
echo "All backups completed!"
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
## Monitoring
|
|
304
|
-
|
|
305
|
-
### Backup Verification
|
|
306
|
-
|
|
307
|
-
1. **Check Backup Size:**
|
|
308
|
-
|
|
309
|
-
```bash
|
|
310
|
-
ls -lh /path/to/backups/
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
2. **Verify Timestamp:**
|
|
314
|
-
|
|
315
|
-
- Ensure backup is recent
|
|
316
|
-
- Check for stale backups
|
|
317
|
-
|
|
318
|
-
3. **Test Restoration:**
|
|
319
|
-
- Periodically test restore process
|
|
320
|
-
- Verify data integrity
|
|
321
|
-
|
|
322
|
-
### Alerts
|
|
323
|
-
|
|
324
|
-
Set up alerts for:
|
|
325
|
-
|
|
326
|
-
- Backup failures
|
|
327
|
-
- Disk space issues
|
|
328
|
-
- Connection problems
|
|
329
|
-
- Unusual backup sizes
|
|
330
|
-
|
|
331
|
-
## Getting Help
|
|
332
|
-
|
|
333
|
-
To see all available options:
|
|
334
|
-
|
|
335
|
-
```bash
|
|
336
|
-
nitor backup -help
|
|
337
|
-
```
|
|
338
|
-
|
|
339
|
-
## Related Commands
|
|
340
|
-
|
|
341
|
-
- `nitor build` - Build before backing up
|
|
342
|
-
- `nitor deploy` - Deploy after backup verification
|
|
343
|
-
- MongoDB tools for manual backup/restore
|