refactor(drivers): organize backup modules into drivers subfolder
lint / docker (push) Has been cancelled
lint / docker (push) Has been cancelled
- Move all backup_*.py files to libtisbackup/drivers/ subdirectory - Move XenAPI.py and copy_vm_xcp.py to drivers/ (driver-specific) - Create drivers/__init__.py with automatic driver imports - Update tisbackup.py imports to use new structure - Add pyvmomi>=8.0.0 as mandatory dependency - Sync requirements.txt with pyproject.toml dependencies - Add pylint>=3.0.0 and pytest-cov>=6.0.0 to dev dependencies - Configure pylint and coverage tools in pyproject.toml - Add conventional commits guidelines to CLAUDE.md - Enhance .gitignore with comprehensive patterns for Python, IDEs, testing, and secrets - Update CLAUDE.md documentation with new structure and tooling Breaking Changes: - Drivers must now be imported from libtisbackup.drivers instead of libtisbackup - All backup driver files relocated to drivers/ subdirectory 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,8 @@ TISBackup is a server-side backup orchestration system written in Python. It exe
|
||||
|
||||
## Development Commands
|
||||
|
||||
**IMPORTANT: Always use `uv run` to execute Python commands in this project.**
|
||||
|
||||
### Dependency Management
|
||||
```bash
|
||||
# Install dependencies (uses uv)
|
||||
@@ -25,37 +27,74 @@ uv lock
|
||||
|
||||
### Linting
|
||||
```bash
|
||||
# Run ruff linter
|
||||
ruff check .
|
||||
# Run ruff linter (fast, primary linter)
|
||||
uv run ruff check .
|
||||
|
||||
# Auto-fix linting issues
|
||||
ruff check --fix .
|
||||
uv run ruff check --fix .
|
||||
|
||||
# Run pylint (comprehensive static analysis)
|
||||
uv run pylint libtisbackup/
|
||||
|
||||
# Run pylint on specific file
|
||||
uv run pylint libtisbackup/ssh.py
|
||||
```
|
||||
|
||||
### Testing
|
||||
```bash
|
||||
# Run all tests
|
||||
uv run pytest
|
||||
|
||||
# Run tests for specific module
|
||||
uv run pytest tests/test_ssh.py
|
||||
|
||||
# Run with verbose output
|
||||
uv run pytest -v
|
||||
|
||||
# Run tests matching a pattern
|
||||
uv run pytest -k "ssh"
|
||||
|
||||
# Run with coverage report
|
||||
uv run pytest --cov=libtisbackup --cov-report=html --cov-report=term-missing
|
||||
|
||||
# Run tests with coverage and show only missing lines
|
||||
uv run pytest --cov=libtisbackup --cov-report=term-missing
|
||||
|
||||
# Generate HTML coverage report (opens in browser)
|
||||
uv run pytest --cov=libtisbackup --cov-report=html
|
||||
# Then open htmlcov/index.html
|
||||
```
|
||||
|
||||
**Coverage reports:**
|
||||
- Terminal report: Shows coverage percentage with missing line numbers
|
||||
- HTML report: Detailed interactive report in `htmlcov/` directory
|
||||
|
||||
See [tests/README.md](tests/README.md) for detailed testing documentation.
|
||||
|
||||
### Running the Application
|
||||
|
||||
**Web GUI (development):**
|
||||
```bash
|
||||
python3 tisbackup_gui.py
|
||||
uv run python tisbackup_gui.py
|
||||
# Runs on port 8080, requires config at /etc/tis/tisbackup_gui.ini
|
||||
```
|
||||
|
||||
**CLI Commands:**
|
||||
```bash
|
||||
# Run backups
|
||||
python3 tisbackup.py -c /etc/tis/tisbackup-config.ini backup
|
||||
uv run python tisbackup.py -c /etc/tis/tisbackup-config.ini backup
|
||||
|
||||
# Run specific backup section
|
||||
python3 tisbackup.py -c /etc/tis/tisbackup-config.ini -s section_name backup
|
||||
uv run python tisbackup.py -c /etc/tis/tisbackup-config.ini -s section_name backup
|
||||
|
||||
# Cleanup old backups
|
||||
python3 tisbackup.py -c /etc/tis/tisbackup-config.ini cleanup
|
||||
uv run python tisbackup.py -c /etc/tis/tisbackup-config.ini cleanup
|
||||
|
||||
# Check backup status (for Nagios)
|
||||
python3 tisbackup.py -c /etc/tis/tisbackup-config.ini checknagios
|
||||
uv run python tisbackup.py -c /etc/tis/tisbackup-config.ini checknagios
|
||||
|
||||
# List available backup drivers
|
||||
python3 tisbackup.py listdrivers
|
||||
uv run python tisbackup.py listdrivers
|
||||
```
|
||||
|
||||
### Docker
|
||||
@@ -79,12 +118,22 @@ docker compose up -d
|
||||
|
||||
**Backup Driver System:**
|
||||
|
||||
All backup logic is implemented via driver classes in [libtisbackup/](libtisbackup/):
|
||||
All backup logic is implemented via driver classes in [libtisbackup/drivers/](libtisbackup/drivers/):
|
||||
|
||||
- Base class: `backup_generic` in [common.py](libtisbackup/common.py:565) (abstract)
|
||||
- Base class: `backup_generic` in [base_driver.py](libtisbackup/base_driver.py) (abstract)
|
||||
- Each driver inherits from `backup_generic` and implements specific backup logic
|
||||
- Drivers are registered via the `register_driver()` decorator function
|
||||
- Configuration is read from INI files using the `read_config()` method
|
||||
- All driver implementations are in [libtisbackup/drivers/](libtisbackup/drivers/) subdirectory
|
||||
|
||||
**Library Modules:**
|
||||
- [base_driver.py](libtisbackup/base_driver.py) - Core `backup_generic` class, driver registry, Nagios states
|
||||
- [database.py](libtisbackup/database.py) - `BackupStat` class for SQLite operations
|
||||
- [ssh.py](libtisbackup/ssh.py) - SSH utilities with modern key support (Ed25519, ECDSA, RSA)
|
||||
- [process.py](libtisbackup/process.py) - Process execution and monitoring utilities
|
||||
- [utils.py](libtisbackup/utils.py) - Date/time formatting, number formatting, validation helpers
|
||||
- [__init__.py](libtisbackup/__init__.py) - Package exports for backward compatibility
|
||||
- [drivers/](libtisbackup/drivers/) - All backup driver implementations
|
||||
|
||||
**Available Drivers:**
|
||||
- `backup_rsync` / `backup_rsync_ssh` - File-based backups via rsync
|
||||
@@ -94,8 +143,8 @@ All backup logic is implemented via driver classes in [libtisbackup/](libtisback
|
||||
- `backup_oracle` - Oracle database backups
|
||||
- `backup_sqlserver` - SQL Server backups
|
||||
- `backup_samba4` - Samba4 AD backups
|
||||
- `backup_xva` / `backup_xcp_metadata` - XenServer VM backups
|
||||
- `backup_vmdk` - VMware VMDK backups
|
||||
- `backup_xva` / `backup_xcp_metadata` / `copy_vm_xcp` - XenServer VM backups
|
||||
- `backup_vmdk` - VMware VMDK backups (requires pyVmomi)
|
||||
- `backup_switch` - Network switch configuration backups
|
||||
- `backup_null` - No-op driver for testing
|
||||
|
||||
@@ -134,15 +183,63 @@ Two-container architecture:
|
||||
- Ruff ignores: F401, F403, F405, E402, E701, E722, E741
|
||||
- Python 3.13+ required
|
||||
|
||||
## Commit Message Guidelines
|
||||
|
||||
**IMPORTANT: This project uses [Conventional Commits](https://www.conventionalcommits.org/) format.**
|
||||
|
||||
All commit messages must follow this format:
|
||||
```
|
||||
<type>(<scope>): <description>
|
||||
|
||||
[optional body]
|
||||
|
||||
[optional footer(s)]
|
||||
```
|
||||
|
||||
**Types:**
|
||||
- `feat`: A new feature
|
||||
- `fix`: A bug fix
|
||||
- `docs`: Documentation only changes
|
||||
- `refactor`: Code change that neither fixes a bug nor adds a feature
|
||||
- `test`: Adding missing tests or correcting existing tests
|
||||
- `chore`: Changes to build process or auxiliary tools
|
||||
- `perf`: Performance improvements
|
||||
- `style`: Code style changes (formatting, missing semicolons, etc.)
|
||||
|
||||
**Scopes (commonly used):**
|
||||
- `auth`: Authentication/authorization changes
|
||||
- `security`: Security-related changes
|
||||
- `drivers`: Backup driver changes
|
||||
- `gui`: Web GUI changes
|
||||
- `api`: API changes
|
||||
- `readme`: README.md changes
|
||||
- `claude`: CLAUDE.md changes
|
||||
- `core`: Core library changes
|
||||
|
||||
**Examples:**
|
||||
- `feat(auth): add pluggable authentication system for Flask routes`
|
||||
- `fix(security): replace os.popen/os.system with subprocess`
|
||||
- `docs(readme): add comprehensive security and authentication documentation`
|
||||
- `refactor(drivers): organize backup modules into drivers subfolder`
|
||||
- `chore(deps): add pyvmomi as mandatory dependency`
|
||||
|
||||
**Breaking Changes:**
|
||||
Add `!` after type/scope for breaking changes:
|
||||
- `feat(api)!: remove deprecated endpoint`
|
||||
|
||||
**Note:** Always include a scope in parentheses, even for documentation changes.
|
||||
|
||||
When Claude Code creates commits, it will automatically follow this format.
|
||||
|
||||
## Important Patterns
|
||||
|
||||
**Adding a new backup driver:**
|
||||
1. Create `backup_<type>.py` in [libtisbackup/](libtisbackup/)
|
||||
1. Create `backup_<type>.py` in [libtisbackup/drivers/](libtisbackup/drivers/)
|
||||
2. Inherit from `backup_generic`
|
||||
3. Set class attributes: `type`, `required_params`, `optional_params`
|
||||
4. Implement abstract methods: `do_backup()`, `cleanup()`, `checknagios()`
|
||||
5. Register with `register_driver(backup_<type>)`
|
||||
6. Import in [tisbackup.py](tisbackup.py)
|
||||
6. Import in [libtisbackup/drivers/__init__.py](libtisbackup/drivers/__init__.py)
|
||||
|
||||
**SSH Operations:**
|
||||
- Uses paramiko for SSH connections
|
||||
|
||||
Reference in New Issue
Block a user