File synchronization service using Confluence API
Project description
Sber-tunnel
File synchronization service using Confluence API as a storage backend.
Features
- Synchronize directories between multiple devices using Confluence
- Automatic file change detection and syncing
- Support for large files (>100MB) with automatic chunking
- Web UI for managing synchronized directories
- CLI interface for easy operation
- Conflict resolution using last-write-wins strategy
Installation
Using pip
pip install -e .
From requirements
pip install -r requirements.txt
Usage
Initialize configuration
sber-tunnel init
This will prompt you for:
- Confluence base URL
- Username
- Password (or API token)
- Page ID for storing files
- Optional: p12 certificate for secure connections
Add directory to sync
sber-tunnel add /path/to/directory
Start sync service
sber-tunnel start
This will start:
- File watcher for automatic change detection
- Web UI at http://127.0.0.1:8000
- Background sync service
Manual sync
sber-tunnel sync
Check status
sber-tunnel status
Stop service
sber-tunnel stop
Architecture
Components
- CLI - Command-line interface built with Click
- FastAPI Server - Web API and UI
- Confluence Service - Handles file upload/download and chunking
- Sync Service - Manages synchronization logic
- File Watcher - Monitors directory changes
- SQLite Database - Local state management
Data Model
manifest.json stored in Confluence contains:
- List of files with path, size, mtime, sha256, version
- Chunk information for large files
- Deletion markers
Local SQLite database contains:
files- File metadata and hashesdirs- Tracked directoriesops- Pending operations queueconfig- Configuration values
File Handling
- Files ≤100MB: Uploaded as single chunk
- Files >100MB: Split into 100MB chunks
- Each chunk verified with SHA256 checksum
- Final file verified after reassembly
Synchronization Strategy
- Download manifest from Confluence
- Scan local directory
- Compare local vs remote state
- Upload changed/new files
- Download remote changes
- Use last-write-wins for conflicts
- Upload updated manifest
Configuration
Configuration is stored in .sber-tunnel/config.json in the directory where you run sber-tunnel
Database is stored in .sber-tunnel/sber-tunnel.db in the same directory
Note: The .sber-tunnel/ directory is created in your current working directory, not in your home directory. This allows you to have different configurations for different projects.
Security
- Credentials stored locally (consider using environment variables in production)
- Full support for p12 certificates - Automatically extracts and uses PEM format
- SHA256 checksums for file integrity
- Hidden and temporary files excluded from sync
- Temporary certificate files with restrictive permissions (600)
- Automatic cleanup of temporary files
Certificate Support
Sber-tunnel fully supports p12 (PKCS#12) certificates for secure authentication:
sber-tunnel init
# When prompted, provide:
# - Path to p12 certificate
# - Certificate password
The service automatically:
- Extracts certificate and private key from p12
- Creates temporary PEM files for use with Confluence API
- Manages file permissions securely
- Cleans up temporary files on shutdown
See docs/CERTIFICATES.md for detailed certificate documentation.
Limitations
- Maximum chunk size: 100MB
- Uses last-write-wins for conflict resolution
- No support for symbolic links
- Hidden files and directories are excluded
Development
Project Structure
sber-tunnel/
├── sber_tunnel/
│ ├── api/ # FastAPI server
│ ├── cli/ # CLI commands
│ ├── core/ # Configuration
│ ├── db/ # Database schema
│ ├── models/ # Data models
│ └── services/ # Business logic
├── tests/ # Unit tests
├── docs/ # Documentation
├── requirements.txt
└── setup.py
Running tests
pytest tests/
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sber_tunnel-1.0.3.tar.gz.
File metadata
- Download URL: sber_tunnel-1.0.3.tar.gz
- Upload date:
- Size: 23.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
890e8beff91b0d3783d1e321e87089586ce8f221e77ff728fe0a3ea412385f76
|
|
| MD5 |
2555ed8efdda356c0870dcaee80ace3b
|
|
| BLAKE2b-256 |
624fb6b8f42bc30b6eba20f2c0f2aa90d9ff4189b29e8663e50c6b49c364edda
|
File details
Details for the file sber_tunnel-1.0.3-py3-none-any.whl.
File metadata
- Download URL: sber_tunnel-1.0.3-py3-none-any.whl
- Upload date:
- Size: 27.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c9a21f1a667b034e9e72e1c7655ba0701bb6beb5dc57ccde9e32fedd446439a
|
|
| MD5 |
ed79c4af6ca008eedf73c86ea1027da7
|
|
| BLAKE2b-256 |
b864e776cefe8003a144bb5fe8c19ea8c5e3cb7dda74c595208d59dd1d6d08ea
|