Skip to main content

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:

Manual sync

sber-tunnel sync

Check status

sber-tunnel status

Stop service

sber-tunnel stop

Architecture

Components

  1. CLI - Command-line interface built with Click
  2. FastAPI Server - Web API and UI
  3. Confluence Service - Handles file upload/download and chunking
  4. Sync Service - Manages synchronization logic
  5. File Watcher - Monitors directory changes
  6. 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 hashes
  • dirs - Tracked directories
  • ops - Pending operations queue
  • config - 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

  1. Download manifest from Confluence
  2. Scan local directory
  3. Compare local vs remote state
  4. Upload changed/new files
  5. Download remote changes
  6. Use last-write-wins for conflicts
  7. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sber_tunnel-1.0.1.tar.gz (23.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sber_tunnel-1.0.1-py3-none-any.whl (26.5 kB view details)

Uploaded Python 3

File details

Details for the file sber_tunnel-1.0.1.tar.gz.

File metadata

  • Download URL: sber_tunnel-1.0.1.tar.gz
  • Upload date:
  • Size: 23.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for sber_tunnel-1.0.1.tar.gz
Algorithm Hash digest
SHA256 e53b3b0852f60e9b7c650ed4b77a17315f4f111db74f2f7e811531a88022ae4a
MD5 53236de75401889cfb20495ac267c985
BLAKE2b-256 ff483f21e30f055ec350d4a256fba9cb661f0a0d03df149292465aaadd6e019b

See more details on using hashes here.

File details

Details for the file sber_tunnel-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: sber_tunnel-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 26.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for sber_tunnel-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 497a06f8e0863e0f5f09d45853068d75e6132f07da1ec434ed6100c7c5677435
MD5 1b58d370dc4157ced1cb9e43ac9471c7
BLAKE2b-256 7ba773fa69d4592d9fc98a7d42423ab35fad27f2741522b171f09f774e627c43

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page