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