starrocks-br 0.3.0__tar.gz → 0.5.0__tar.gz

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.
Files changed (53) hide show
  1. starrocks_br-0.5.0/PKG-INFO +153 -0
  2. starrocks_br-0.5.0/README.md +137 -0
  3. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/pyproject.toml +27 -2
  4. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/src/starrocks_br/cli.py +307 -217
  5. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/src/starrocks_br/concurrency.py +50 -50
  6. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/src/starrocks_br/config.py +31 -23
  7. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/src/starrocks_br/db.py +38 -38
  8. starrocks_br-0.5.0/src/starrocks_br/error_handler.py +265 -0
  9. starrocks_br-0.5.0/src/starrocks_br/exceptions.py +93 -0
  10. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/src/starrocks_br/executor.py +102 -73
  11. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/src/starrocks_br/health.py +1 -6
  12. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/src/starrocks_br/history.py +5 -8
  13. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/src/starrocks_br/labels.py +14 -10
  14. starrocks_br-0.5.0/src/starrocks_br/logger.py +66 -0
  15. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/src/starrocks_br/planner.py +112 -111
  16. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/src/starrocks_br/repository.py +3 -5
  17. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/src/starrocks_br/restore.py +241 -191
  18. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/src/starrocks_br/schema.py +15 -14
  19. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/src/starrocks_br/timezone.py +29 -31
  20. starrocks_br-0.5.0/src/starrocks_br/utils.py +86 -0
  21. starrocks_br-0.5.0/src/starrocks_br.egg-info/PKG-INFO +153 -0
  22. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/src/starrocks_br.egg-info/SOURCES.txt +6 -1
  23. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/src/starrocks_br.egg-info/requires.txt +2 -0
  24. starrocks_br-0.5.0/tests/test_cli.py +1351 -0
  25. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/tests/test_concurrency.py +43 -39
  26. starrocks_br-0.5.0/tests/test_config.py +174 -0
  27. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/tests/test_db.py +119 -114
  28. starrocks_br-0.5.0/tests/test_error_handler.py +169 -0
  29. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/tests/test_executor.py +347 -154
  30. starrocks_br-0.5.0/tests/test_health_checks.py +169 -0
  31. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/tests/test_history.py +0 -2
  32. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/tests/test_labels.py +30 -37
  33. starrocks_br-0.5.0/tests/test_logger.py +78 -0
  34. starrocks_br-0.5.0/tests/test_planner.py +720 -0
  35. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/tests/test_repository_sql.py +23 -6
  36. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/tests/test_restore.py +661 -398
  37. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/tests/test_schema_setup.py +51 -49
  38. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/tests/test_timezone.py +163 -138
  39. starrocks_br-0.5.0/tests/test_utils.py +121 -0
  40. starrocks_br-0.3.0/PKG-INFO +0 -456
  41. starrocks_br-0.3.0/README.md +0 -442
  42. starrocks_br-0.3.0/src/starrocks_br/logger.py +0 -36
  43. starrocks_br-0.3.0/src/starrocks_br.egg-info/PKG-INFO +0 -456
  44. starrocks_br-0.3.0/tests/test_cli.py +0 -804
  45. starrocks_br-0.3.0/tests/test_config.py +0 -78
  46. starrocks_br-0.3.0/tests/test_health_checks.py +0 -61
  47. starrocks_br-0.3.0/tests/test_logger.py +0 -256
  48. starrocks_br-0.3.0/tests/test_planner.py +0 -513
  49. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/setup.cfg +0 -0
  50. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/src/starrocks_br/__init__.py +0 -0
  51. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/src/starrocks_br.egg-info/dependency_links.txt +0 -0
  52. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/src/starrocks_br.egg-info/entry_points.txt +0 -0
  53. {starrocks_br-0.3.0 → starrocks_br-0.5.0}/src/starrocks_br.egg-info/top_level.txt +0 -0
@@ -0,0 +1,153 @@
1
+ Metadata-Version: 2.4
2
+ Name: starrocks-br
3
+ Version: 0.5.0
4
+ Summary: StarRocks Backup and Restore automation tool
5
+ Requires-Python: >=3.10
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: click<9,>=8.1.7
8
+ Requires-Dist: PyYAML<7,>=6.0.1
9
+ Requires-Dist: mysql-connector-python<10,>=9.0.0
10
+ Provides-Extra: dev
11
+ Requires-Dist: pytest<9,>=8.3.2; extra == "dev"
12
+ Requires-Dist: pytest-mock<4,>=3.14.0; extra == "dev"
13
+ Requires-Dist: pytest-cov<6,>=5.0.0; extra == "dev"
14
+ Requires-Dist: ruff<1,>=0.8.0; extra == "dev"
15
+ Requires-Dist: pre-commit<5,>=4.0.0; extra == "dev"
16
+
17
+ # StarRocks Backup & Restore
18
+
19
+ Full and incremental backup automation for StarRocks shared-nothing clusters.
20
+
21
+ **Requirements:** StarRocks 3.5+ (shared-nothing mode)
22
+
23
+ 📋 **[Release Notes & Changelog](CHANGELOG.md)**
24
+
25
+ ## Table of Contents
26
+
27
+ - [Why This Tool?](#why-this-tool)
28
+ - [Documentation](#documentation)
29
+ - [Installation](#installation)
30
+ - [Configuration](#configuration)
31
+ - [Basic Usage](#basic-usage)
32
+ - [How It Works](#how-it-works)
33
+
34
+ ## Why This Tool?
35
+
36
+ StarRocks provides native `BACKUP` and `RESTORE` commands, but they only support full backups. For large-scale deployments hosting data at petabyte scale, full backups are not feasible due to time, storage, and network constraints.
37
+
38
+ This tool adds **incremental backup capabilities** to StarRocks by leveraging native partition-based backup features.
39
+
40
+ **What StarRocks doesn't provide:**
41
+ - ❌ **No incremental backups** - You must manually identify changed partitions and build complex backup commands
42
+ - ❌ **No backup history** - No built-in way to track what was backed up, when, or which backups succeeded/failed
43
+ - ❌ **No restore intelligence** - You manually determine which backups are needed for point-in-time recovery
44
+ - ❌ **No organization** - No way to group tables or manage different backup strategies
45
+ - ❌ **No concurrency control** - Multiple backup operations can conflict
46
+
47
+ **What this tool provides:**
48
+ - ✅ **Automatic incremental backups** - Tool detects changed partitions since the last full backup automatically
49
+ - ✅ **Complete operation tracking** - Every backup and restore is logged with status, timestamps, and error details
50
+ - ✅ **Intelligent restore** - Automatically resolves backup chains (full + incremental) for you
51
+ - ✅ **Inventory groups** - Organize tables into groups with different backup strategies
52
+ - ✅ **Job concurrency control** - Prevents conflicting operations
53
+ - ✅ **Safe restores** - Atomic rename mechanism prevents data loss during restore
54
+ - ✅ **Metadata management** - Dedicated `ops` database tracks all backup metadata and partition manifests
55
+
56
+ In short: this tool transforms StarRocks's basic backup/restore commands into a **production-ready incremental backup solution**.
57
+
58
+ ## Documentation
59
+
60
+ - **[Getting Started](docs/getting-started.md)** - Step-by-step tutorial
61
+ - **[Core Concepts](docs/core-concepts.md)** - Understand inventory groups, backup types, and restore chains
62
+ - **[Installation](docs/installation.md)** - All installation methods
63
+ - **[Configuration](docs/configuration.md)** - Config file reference and TLS setup
64
+ - **[Commands](docs/commands.md)** - Detailed command reference
65
+ - **[Scheduling & Monitoring](docs/scheduling.md)** - Automate backups and monitor status
66
+
67
+ ## Installation
68
+
69
+ ### Option 1: PyPI
70
+
71
+ ```bash
72
+ python3 -m venv .venv
73
+ source .venv/bin/activate
74
+ pip install starrocks-br
75
+ ```
76
+
77
+ ### Option 2: Standalone Executable
78
+
79
+ Download from [releases](https://github.com/deep-bi/starrocks-br/releases/latest):
80
+
81
+ ```bash
82
+ # Linux
83
+ chmod +x starrocks-br-linux-x86_64
84
+ mv starrocks-br-linux-x86_64 starrocks-br
85
+ ./starrocks-br --help
86
+ ```
87
+
88
+ See [Installation Guide](docs/installation.md) for all options.
89
+
90
+ ## Configuration
91
+
92
+ Create a `config.yaml` file pointing to your StarRocks cluster:
93
+
94
+ ```yaml
95
+ host: "127.0.0.1" # StarRocks FE node address
96
+ port: 9030 # MySQL protocol port
97
+ user: "root" # Database user with backup/restore privileges
98
+ database: "your_database" # Database containing tables to backup
99
+ repository: "your_repo_name" # Repository created via CREATE REPOSITORY in StarRocks
100
+ ```
101
+
102
+ Set password:
103
+ ```bash
104
+ export STARROCKS_PASSWORD="your_password"
105
+ ```
106
+
107
+ See [Configuration Reference](docs/configuration.md) for TLS and advanced options.
108
+
109
+ ## Basic Usage
110
+
111
+ **Initialize:**
112
+ ```bash
113
+ starrocks-br init --config config.yaml
114
+ ```
115
+
116
+ **Define inventory groups** (in StarRocks):
117
+ ```sql
118
+ INSERT INTO ops.table_inventory (inventory_group, database_name, table_name)
119
+ VALUES
120
+ ('production', 'mydb', 'users'),
121
+ ('production', 'mydb', 'orders');
122
+ ```
123
+
124
+ **Backup:**
125
+ ```bash
126
+ # Full backup
127
+ starrocks-br backup full --config config.yaml --group production
128
+
129
+ # Incremental backup (tool detects changed partitions automatically)
130
+ starrocks-br backup incremental --config config.yaml --group production
131
+ ```
132
+
133
+ **Restore:**
134
+ ```bash
135
+ # Tool automatically resolves backup chains
136
+ starrocks-br restore --config config.yaml --target-label mydb_20251118_full
137
+ ```
138
+
139
+ See [Commands Reference](docs/commands.md) for all options.
140
+
141
+ ## How It Works
142
+
143
+ 1. **Inventory Groups**: Define collections of tables that share the same backup strategy
144
+ 2. **ops Database**: Tool creates an `ops` database to track all operations and metadata
145
+ 3. **Automatic Incrementals**: Tool queries partition metadata and compares with the baseline to detect changes
146
+ 4. **Intelligent Restore**: Automatically resolves backup chains (full + incremental) for point-in-time recovery
147
+ 5. **Safe Operations**: All restores use temporary tables with atomic rename for safety
148
+
149
+ Read [Core Concepts](docs/core-concepts.md) for detailed explanations.
150
+
151
+ ## Contributing
152
+
153
+ We welcome contributions! See issues for areas that need help or create a new issue to report a bug or request a feature.
@@ -0,0 +1,137 @@
1
+ # StarRocks Backup & Restore
2
+
3
+ Full and incremental backup automation for StarRocks shared-nothing clusters.
4
+
5
+ **Requirements:** StarRocks 3.5+ (shared-nothing mode)
6
+
7
+ 📋 **[Release Notes & Changelog](CHANGELOG.md)**
8
+
9
+ ## Table of Contents
10
+
11
+ - [Why This Tool?](#why-this-tool)
12
+ - [Documentation](#documentation)
13
+ - [Installation](#installation)
14
+ - [Configuration](#configuration)
15
+ - [Basic Usage](#basic-usage)
16
+ - [How It Works](#how-it-works)
17
+
18
+ ## Why This Tool?
19
+
20
+ StarRocks provides native `BACKUP` and `RESTORE` commands, but they only support full backups. For large-scale deployments hosting data at petabyte scale, full backups are not feasible due to time, storage, and network constraints.
21
+
22
+ This tool adds **incremental backup capabilities** to StarRocks by leveraging native partition-based backup features.
23
+
24
+ **What StarRocks doesn't provide:**
25
+ - ❌ **No incremental backups** - You must manually identify changed partitions and build complex backup commands
26
+ - ❌ **No backup history** - No built-in way to track what was backed up, when, or which backups succeeded/failed
27
+ - ❌ **No restore intelligence** - You manually determine which backups are needed for point-in-time recovery
28
+ - ❌ **No organization** - No way to group tables or manage different backup strategies
29
+ - ❌ **No concurrency control** - Multiple backup operations can conflict
30
+
31
+ **What this tool provides:**
32
+ - ✅ **Automatic incremental backups** - Tool detects changed partitions since the last full backup automatically
33
+ - ✅ **Complete operation tracking** - Every backup and restore is logged with status, timestamps, and error details
34
+ - ✅ **Intelligent restore** - Automatically resolves backup chains (full + incremental) for you
35
+ - ✅ **Inventory groups** - Organize tables into groups with different backup strategies
36
+ - ✅ **Job concurrency control** - Prevents conflicting operations
37
+ - ✅ **Safe restores** - Atomic rename mechanism prevents data loss during restore
38
+ - ✅ **Metadata management** - Dedicated `ops` database tracks all backup metadata and partition manifests
39
+
40
+ In short: this tool transforms StarRocks's basic backup/restore commands into a **production-ready incremental backup solution**.
41
+
42
+ ## Documentation
43
+
44
+ - **[Getting Started](docs/getting-started.md)** - Step-by-step tutorial
45
+ - **[Core Concepts](docs/core-concepts.md)** - Understand inventory groups, backup types, and restore chains
46
+ - **[Installation](docs/installation.md)** - All installation methods
47
+ - **[Configuration](docs/configuration.md)** - Config file reference and TLS setup
48
+ - **[Commands](docs/commands.md)** - Detailed command reference
49
+ - **[Scheduling & Monitoring](docs/scheduling.md)** - Automate backups and monitor status
50
+
51
+ ## Installation
52
+
53
+ ### Option 1: PyPI
54
+
55
+ ```bash
56
+ python3 -m venv .venv
57
+ source .venv/bin/activate
58
+ pip install starrocks-br
59
+ ```
60
+
61
+ ### Option 2: Standalone Executable
62
+
63
+ Download from [releases](https://github.com/deep-bi/starrocks-br/releases/latest):
64
+
65
+ ```bash
66
+ # Linux
67
+ chmod +x starrocks-br-linux-x86_64
68
+ mv starrocks-br-linux-x86_64 starrocks-br
69
+ ./starrocks-br --help
70
+ ```
71
+
72
+ See [Installation Guide](docs/installation.md) for all options.
73
+
74
+ ## Configuration
75
+
76
+ Create a `config.yaml` file pointing to your StarRocks cluster:
77
+
78
+ ```yaml
79
+ host: "127.0.0.1" # StarRocks FE node address
80
+ port: 9030 # MySQL protocol port
81
+ user: "root" # Database user with backup/restore privileges
82
+ database: "your_database" # Database containing tables to backup
83
+ repository: "your_repo_name" # Repository created via CREATE REPOSITORY in StarRocks
84
+ ```
85
+
86
+ Set password:
87
+ ```bash
88
+ export STARROCKS_PASSWORD="your_password"
89
+ ```
90
+
91
+ See [Configuration Reference](docs/configuration.md) for TLS and advanced options.
92
+
93
+ ## Basic Usage
94
+
95
+ **Initialize:**
96
+ ```bash
97
+ starrocks-br init --config config.yaml
98
+ ```
99
+
100
+ **Define inventory groups** (in StarRocks):
101
+ ```sql
102
+ INSERT INTO ops.table_inventory (inventory_group, database_name, table_name)
103
+ VALUES
104
+ ('production', 'mydb', 'users'),
105
+ ('production', 'mydb', 'orders');
106
+ ```
107
+
108
+ **Backup:**
109
+ ```bash
110
+ # Full backup
111
+ starrocks-br backup full --config config.yaml --group production
112
+
113
+ # Incremental backup (tool detects changed partitions automatically)
114
+ starrocks-br backup incremental --config config.yaml --group production
115
+ ```
116
+
117
+ **Restore:**
118
+ ```bash
119
+ # Tool automatically resolves backup chains
120
+ starrocks-br restore --config config.yaml --target-label mydb_20251118_full
121
+ ```
122
+
123
+ See [Commands Reference](docs/commands.md) for all options.
124
+
125
+ ## How It Works
126
+
127
+ 1. **Inventory Groups**: Define collections of tables that share the same backup strategy
128
+ 2. **ops Database**: Tool creates an `ops` database to track all operations and metadata
129
+ 3. **Automatic Incrementals**: Tool queries partition metadata and compares with the baseline to detect changes
130
+ 4. **Intelligent Restore**: Automatically resolves backup chains (full + incremental) for point-in-time recovery
131
+ 5. **Safe Operations**: All restores use temporary tables with atomic rename for safety
132
+
133
+ Read [Core Concepts](docs/core-concepts.md) for detailed explanations.
134
+
135
+ ## Contributing
136
+
137
+ We welcome contributions! See issues for areas that need help or create a new issue to report a bug or request a feature.
@@ -4,10 +4,10 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "starrocks-br"
7
- version = "0.3.0"
7
+ version = "0.5.0"
8
8
  description = "StarRocks Backup and Restore automation tool"
9
9
  readme = "README.md"
10
- requires-python = ">=3.9"
10
+ requires-python = ">=3.10"
11
11
  dependencies = [
12
12
  "click>=8.1.7,<9",
13
13
  "PyYAML>=6.0.1,<7",
@@ -19,6 +19,8 @@ dev = [
19
19
  "pytest>=8.3.2,<9",
20
20
  "pytest-mock>=3.14.0,<4",
21
21
  "pytest-cov>=5.0.0,<6",
22
+ "ruff>=0.8.0,<1",
23
+ "pre-commit>=4.0.0,<5",
22
24
  ]
23
25
 
24
26
  [project.scripts]
@@ -43,3 +45,26 @@ skip_covered = false
43
45
 
44
46
  [tool.black]
45
47
  line-length = 100
48
+
49
+ [tool.ruff]
50
+ line-length = 100
51
+ target-version = "py310"
52
+
53
+ [tool.ruff.lint]
54
+ select = [
55
+ "E", # pycodestyle errors
56
+ "F", # pyflakes (unused imports, variables, etc.)
57
+ "I", # isort (import sorting)
58
+ "N", # pep8-naming
59
+ "UP", # pyupgrade (modernize Python code)
60
+ "B", # flake8-bugbear (likely bugs)
61
+ "C4", # flake8-comprehensions
62
+ "ARG", # flake8-unused-arguments (unused function parameters)
63
+ ]
64
+ ignore = [
65
+ "E501", # Line too long (let Black handle line length)
66
+ ]
67
+
68
+ [tool.ruff.lint.per-file-ignores]
69
+ "__init__.py" = ["F401"] # Allow unused imports in __init__.py files
70
+ "tests/**" = ["ARG001"] # Allow unused arguments in tests (pytest fixtures)