Fetch'n'Backup - Simple two-step backup tool with rsync
Project description
fnb โ Fetch'n'Backup
fnb is a simple two-step backup tool, powered by rsync.
It gives you two handy commands:
fetch (to pull from remote), and
backup (to save to somewhere safe).
Under the hood? Just good old rsync โ no magic, just sharp automation.
- Simple config. Sharp execution. Safe data.
- Use them one by one, or
syncthem all in one go.
๐ Features
- Fetch โ Retrieve data from a remote server to your local machine
- Backup โ Save local data to external storage
- Sync โ Run Fetch and Backup together in one go
- Init โ Generate an initial config file (
fnb.toml) - Structured Logging โ Built-in logging with configurable verbosity levels and file output
โ๏ธ Installation
From PyPI (Recommended)
pip install fnb
# ใพใใฏ
uv pip install fnb
From Source
git clone https://gitlab.com/qumasan/fnb.git
cd fnb
uv pip install -e .
Requirements: Python 3.12 or higher is required.
๐งฐ Quick Start
# Initialize configuration files (fnb.toml and .env files)
fnb init
# Check the current config
fnb status
# Fetch: remote -> local
fnb fetch TARGET_LABEL
# Backup: local -> external
fnb backup TARGET_LABEL
# Run Fetch โ Backup in one go
fnb sync TARGET_LABEL
# Check version
fnb version
# Logging and Verbosity Control
# Adjust log level for detailed output
fnb fetch TARGET_LABEL --log-level DEBUG
fnb sync TARGET_LABEL --verbose # Same as --log-level DEBUG
fnb backup TARGET_LABEL --quiet # Same as --log-level WARNING
# Log files are automatically saved to:
# macOS: ~/Library/Logs/fnb/fnb.log
# Linux: ~/.local/share/fnb/fnb.log
๐ง Configuration
fnb uses TOML configuration files with sections for fetch and backup operations:
[fetch.SECTION_NAME]
label = "TARGET_LABEL"
summary = "Fetch data from remote server"
host = "user@remote-host"
source = "~/path/to/source/"
target = "./local/backup/path/"
options = ["-auvz", "--delete", '--rsync-path="~/.local/bin/rsync"']
enabled = true
[backup.SECTION_NAME]
label = "TARGET_LABEL"
summary = "Backup data to cloud storage"
host = "none" # Local operation
source = "./local/backup/path/" # Output from fetch
target = "./cloud/backup/path/"
options = ["-auvz", "--delete"]
enabled = true
Configuration File Priority (highest to lowest)
./fnb.tomlโ Project-local configuration~/.config/fnb/config.tomlโ Global user configuration (XDG standard)C:\Users\username\AppData\Local\fnb\config.tomlโ Windows global configuration./config/*.tomlโ Split configuration for development/operations
๐ Logging
fnb includes built-in structured logging powered by loguru. All operations are logged with configurable verbosity levels.
Log Levels
- DEBUG โ Detailed debugging information, command traces, and internal state
- INFO โ General operational information, task progress, success/failure messages (default)
- WARNING โ Important notices, non-critical issues, fallback actions
- ERROR โ Error conditions, operation failures, critical issues
Log Output
Console Output (stderr)
- Colored, structured format with timestamps
- User-facing messages on stdout (status, progress)
- Internal logging on stderr (debug, technical details)
Log Files (automatic)
- macOS:
~/Library/Logs/fnb/fnb.log - Linux:
~/.local/share/fnb/fnb.log - Windows:
%APPDATA%\qumasan\fnb\Logs\fnb.log
File Log Management
- Rotation: Automatic rotation when files reach 10MB
- Retention: Keeps logs for 7 days
- Compression: Old logs compressed with gzip
- Disable: Set
FNB_DISABLE_FILE_LOGGING=1to disable file logging
Command Examples
# Default INFO level logging
fnb sync logs
# Verbose debugging output
fnb fetch logs --verbose
fnb sync logs --log-level DEBUG
# Quiet mode (warnings and errors only)
fnb backup logs --quiet
fnb fetch logs --log-level WARNING
# Custom log level
fnb sync logs --log-level ERROR
๐ Authentication
SSH password input can be automated using pexpect.
You can also define connection settings in a .env file if needed.
Run fnb init env to create the initial .env file.
๐ What's New in v0.12.3
๐ ๏ธ Development Workflow Improvements
- Restructured Task File - Reorganized task definitions following standardized pattern for better organization and clarity
- Enhanced Task Management - New convenience tasks:
env:setup,env:clean,status,log,push,push:tags,push:release - Improved Type Safety - Fixed type checking issues in
options.pyfor stricter type compliance - Dependency Updates - Updated 68 packages to latest versions
๐ Expanded Documentation
- Release Note Templates - New
docs:releasetask for structured release documentation - Version Management - Simplified with
bump:auto,bump:patch,bump:minor,bump:majorcommands - Release Notes Structure - vX.Y.Z release notes in docs/releases/ with comprehensive information
๐ ReadTheDocs Documentation Platform Integration (v0.11.2)
- Versioned Documentation - Automatic documentation builds for each Git tag
- Multi-format Output - HTML, EPUB, and HTMLZip formats available
- Version Selector - Easy switching between documentation versions
- Public Documentation - Professional documentation hosting at https://fnb.readthedocs.io/
๐ง Enhanced Documentation Infrastructure (v0.11.2)
- Automated Builds - Documentation automatically builds on tag push
- Material Theme Support - Full mkdocs-material compatibility with ReadTheDocs
- Stable URLs - Each version accessible at predictable URLs
- Search Integration - Full-text search across all versions
๐งช Development
Python 3.12+โ Version requirementuvโ Package managementTyperโ CLI frameworkPydanticโ Configuration validationpexpectโ SSH automationpython-dotenvโ Environment variable supportpytestโ Testing framework (80% coverage)mkdocs-materialโ Documentation with i18n supportpre-commitโ Run checks before each commitruffโ Fast Python linter and formattercommitizenโ Conventional commit tagging and changelog automationrenovateโ Automated dependency management
Release Management
This project uses automated semantic versioning with structured release workflow:
Complete Release Workflow
Option 1: Automated Full Release (v0.12.3)
task release:full # test โ format โ bump โ release
Option 2: Step-by-Step Release (New in v0.12.3)
# Step 1: Verify changes and run tests
task test:ci # Run all tests and checks
# Step 2: Preview and execute version bump
task bump:check # Preview version changes
task bump:patch # Bump patch version (or bump:minor/bump:major)
# Step 3: Create release notes from template
task docs:release -- X.Y.Z # Create vX.Y.Z.md from template
# Edit docs/releases/vX.Y.Z.md with detailed release information
# Step 4: Commit release notes
git add docs/releases/vX.Y.Z.md mkdocs.yml
git commit -m "docs: add vX.Y.Z release notes"
# Step 5: Push release to GitLab with notes file
task push:release -- X.Y.Z # Creates GitLab release with release notes
# Step 6: Verify TestPyPI deployment (automatic on tag push)
VERSION=X.Y.Z task verify:testpypi
# Step 7: Production PyPI deployment (when ready)
task publish:prod
Release Timeline
- Code Changes โ Commit with conventional commit format
- Version Bump โ
task version:bumpcreates tag and updates files - Tag Push โ
task releasepushes tags and creates GitLab release - TestPyPI Deploy โ Automatic CI deployment on tag push
- Release Notes โ Manual creation of detailed release documentation
- Documentation โ Update navigation and release index
- PyPI Deploy โ Manual production deployment when ready
Current Version: v0.12.3 - View Release
CI/CD Pipeline
GitLab CI/CD pipeline provides automated testing, building, and deployment:
Stages:
renovate: Automated dependency management (optional)test: Unit tests, code quality, Renovate-specific testsdocs-quality: Documentation build validationbuild: Package building withuv builddeploy-test: TestPyPI deployment (automatic on tag push) ๐deploy-prod: PyPI deployment (manual approval for safety)
Automated Workflows:
# Deployment (v0.10.0)
tag push โ [Auto TestPyPI] โ Local Verification โ [Manual PyPI]
# Dependency Management (v0.11.0)
Monday 6am JST โ [Renovate Scan] โ [Auto MR] โ [Enhanced Testing]
Optional CI Variables:
# GitLab Settings โ CI/CD โ Variables
TESTPYPI_API_TOKEN # TestPyPI API token for testing releases
PYPI_API_TOKEN # PyPI API token for production releases
RENOVATE_TOKEN # GitLab token for automated dependency updates (new in v0.11.0)
Local CI Simulation:
# Run tests as they run in CI (unit tests only)
task test:ci
# Run unit tests only (fast feedback)
task test:unit
# Run integration tests only
task test:integration
# Run all tests
task test
# Verify TestPyPI deployment
VERSION=0.12.3 task verify:testpypi
# Dependency management tasks (new in v0.11.0)
task deps:update # Update all dependencies
task deps:test # Test with updated dependencies
task deps:security # Check for security vulnerabilities
Test Structure
Tests are organized into two directories for optimal development workflow:
- tests/unit/: 9 files, 124 tests - Fast unit tests (1.65s)
- tests/integration/: 1 file, 23 tests - Comprehensive workflow tests (3.25s)
Both directory-based and marker-based execution are supported:
# Directory-based (recommended)
task test:unit # tests/unit/ only
task test:integration # tests/integration/ only
# Marker-based (backward compatibility)
pytest -m "not integration" # unit tests
pytest -m "integration" # integration tests
Test Coverage
Current test coverage is 80% with comprehensive error handling and integration testing:
- Unit Tests: 124 tests covering all modules
- Integration Tests: 23 tests covering complete workflows
- Test Execution: ~0.61s for unit tests, full test suite in <5s
See CLAUDE.md for detailed test structure and module-level coverage information.
๐ชช License
MIT
๐ ๏ธ Contributing
This project is maintained in two repositories:
- ๐ ๏ธ Development, Issues, Merge Requests: GitLab
- ๐ Public Mirror and Discussions: GitHub
- ๐ฆ PyPI Package: fnb
- ๐ Documentation: ReadTheDocs with versioned documentation
- ๐ Legacy Docs: GitLab Pages (maintained for reference)
Please use GitLab for development contributions, bug reports, and feature requests. For documentation viewing and community discussions, feel free to visit the GitHub mirror.
Development Workflow
See CLAUDE.md for detailed development guidelines including:
- Testing and coverage requirements (83%+)
- Version management and release workflow
- GitLab integration best practices
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 fnb-0.12.3.tar.gz.
File metadata
- Download URL: fnb-0.12.3.tar.gz
- Upload date:
- Size: 1.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
552263a8e109eea180594534243ec9a01c7a11af60b9cbfa718ad5d51af9c640
|
|
| MD5 |
3c3b52f9759c806d32886d08593909f4
|
|
| BLAKE2b-256 |
22aa0e1015d4aaa7115c8e3291d0652c49825629faad838f409a11826e363fd5
|
File details
Details for the file fnb-0.12.3-py3-none-any.whl.
File metadata
- Download URL: fnb-0.12.3-py3-none-any.whl
- Upload date:
- Size: 35.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
976847b6806892991d52c9d48db891856813a7b843a1d9c7be384526fb46ecbd
|
|
| MD5 |
feb57604bbb3c994d69bcb3b4f4ac7d8
|
|
| BLAKE2b-256 |
25b0e8558224dc781db09ddfba588134ff908409d791ce558d7067c4ca844d9b
|