Repository navigation
feat: mongodb-exclude-collections #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5a372d0
19c3801
8d8a355
67692ff
57c7af4
3f289e3
d7dbf30
c449e24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,3 +10,4 @@ __pycache__/ | |
| .codex/ | ||
| /docs | ||
| test/ | ||
| .idea | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,6 +73,29 @@ def option_fields(self) -> list[Field]: | |
| default=False, | ||
| help="When enabled, adds tls=true to the URI to force a TLS connection.", | ||
| ), | ||
| Field( | ||
| "exclude_collections", | ||
| "Exclude collections", | ||
| "list", | ||
| default=[], | ||
| help=( | ||
| "Comma-separated collection names (mongodump " | ||
| "--excludeCollection), e.g. events,sessions. Leave empty to " | ||
|
Comment on lines
+79
to
+83
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| "dump every collection. Collections already in the restore " | ||
| "target are left untouched. Requires Agent 1.26.0+." | ||
| ), | ||
| ), | ||
| Field( | ||
| "exclude_collections_with_prefix", | ||
| "Exclude collections with prefix", | ||
| "list", | ||
| default=[], | ||
| help=( | ||
| "Comma-separated collection name prefixes (mongodump " | ||
| "--excludeCollectionsWithPrefix), e.g. cache_,tmp_. Leave empty " | ||
| "to dump every collection. Requires Agent 1.26.0+." | ||
| ), | ||
| ), | ||
| ] | ||
|
|
||
| def generate( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import pytest | ||
|
|
||
| import main | ||
|
|
||
| CASES = [ | ||
| ([], 0), | ||
| (["--version"], 0), | ||
| (["no-such-command"], 2), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| (["db"], 2), | ||
| (["agent", "--bogus"], 2), | ||
| ] | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| ("argv", "exit_code"), CASES, ids=[" ".join(argv) or "no-args" for argv, _ in CASES] | ||
| ) | ||
| def cli_errors_map_to_exit_codes(monkeypatch, tmp_path, argv, exit_code): | ||
| monkeypatch.setenv("HOME", str(tmp_path)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| monkeypatch.setattr("sys.argv", ["portabase", *argv]) | ||
| with pytest.raises(SystemExit) as raised: | ||
| main.main() | ||
| assert raised.value.code == exit_code | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: Portabase/cli
Length of output: 5902
Script executed:
Repository: Portabase/cli
Length of output: 18713
Web query:
Portabase agent github mongodb exclude_collections exclude_collections_with_prefix mongodump 1.26.0Result:
Script executed:
Repository: Portabase/cli
Length of output: 37424
Script executed:
Repository: Portabase/cli
Length of output: 10132
Web query:
site:github.com/portabase/agent "exclude_collections" mongodb "mongodump" agentResult:
Script executed:
Repository: Portabase/cli
Length of output: 42283
Web query:
Portabase agent Docker Hub latest image version 1.25.2 1.26.0 mongodb exclusionResult:
Script executed:
Repository: Portabase/cli
Length of output: 17289
Web query:
MongoDB database tools mongodump --excludeCollection exclude multiple database uri official documentationResult:
Add Agent support before exposing these options.
The CLI writes both keys to
databases.json, but Agent 1.25.2 ignores them when buildingmongodump. The generated command omits both exclusion flags, so the backup succeeds with excluded collections still included. The currentlatestimage also corresponds to Agent 1.25.2, not 1.26.0.