Major Announcement: Duplicity 4.0 Architecture & Feature Overhaul (pre-release)
We are proud to announce the comprehensive architectural modernization and release overhaul of Duplicity 4.0, incorporating all major milestones and enhancements developed from rel.4.0.0.dev0 through rel.4.0.0.dev12 (Merge Request !408).
This milestone represents a complete engineering refactoring of Duplicity designed to deliver maximum operational utility, optimal resource stewardship, and robust data protection for systems of all scales. By eliminating bottlenecks, bounding storage and memory overhead, accelerating multi-core throughput, and establishing native cryptography and compression subsystems, Duplicity 4.0 significantly reduces execution times, hardware wear, storage costs, and administrative complexity while preserving full backward compatibility for historical backups.
Key User-Oriented Enhancements & Operational Value
High-Throughput Native Streaming AEAD Cryptography
- In-Process Streaming AEAD Engine (
src/crypto.py): Replaced external subprocess GnuPG pipes with a native, in-process authenticated encryption engine based on Python'scryptographylibrary. Supports chunked authenticated encryption usingAES-256-GCM(default) andChaCha20-Poly1305within a structured streaming container (DUPENC). - Robust Key Encapsulation: Employs industry-standard symmetric key derivation (
Scrypt/HKDF) and modern asymmetric hybrid public-key encryption (X25519). - Zero Subprocess Overhead & Deadlock Elimination: Fully removes GnuPG pipe stalls, socket path length limits, and keyring lock contentions (such as
pubring.kbx.lockdeadlocks) during concurrent multi-volume processing. - Unified
--crypto-*CLI Options: Replaced fragmented, backend-specific flags with an intuitive interface (--crypto-backend,--crypto-cipher,--crypto-passphrase,--crypto-pubkey, and--crypto-privkey), with transparent backward-compatible aliases for legacy--gpg-options,--encrypt-key, and--hidden-encrypt-key. - Automated Keyring Inspection: Automatically detects whether asymmetric keys require passphrases (
key_needs_passphrase), eliminating redundant prompts when utilizing passwordless keys.
Modern High-Efficiency Compression (zstd, zlib-ng) & Architecture Decoupling
- Native Zstandard (
zstd) by Default: Integrated high-speed, high-ratiozstandardcompression (--compression-algo=zstd) across archive volumes, manifests, signatures, and statistics files (.zst), substantially reducing bandwidth and storage consumption while dramatically speeding up decompression. - SIMD-Accelerated Compression (
zlib-ng): Integratedzlib-nghardware acceleration (src/dup_tarfile.py) leveraging AVX-512, AVX2, and NEON instruction sets to eliminate single-threaded compression bottlenecks. - Decoupled Architecture: Fully decoupled compression from encryption, enabling independent algorithm selection, pre-encryption compression, and inspectable compressed metadata.
Space-Bounded (O(1)) Restore, Verification & Fast Comparison
- Sequential In-Place Restore Pipeline: Overhauled
duplicity restoreto execute sequentially in forward chronological order. Base full backups extract volume-by-volume directly into target destinations, followed by chronological application of incremental delta patches via atomic temporary sibling replacements (.dup_tmpwithos.replace). This bounds peak temporary disk usage to a single volume (O(1)) regardless of chain length and eliminates disk exhaustion inTMPDIR. - Concurrent Volume Prefetcher: Overlaps network download latency with local CPU decryption, signature verification, tar extraction, and filesystem writing while strictly capping local disk usage to
(config.concurrency + 1) * config.volsize. - Space-Bounded Archive Verification (
duplicity verify): Implemented sequential archive integrity validation that verifies remote volume SHA-1/MD5 checksums against manifests, validates signatures, and checks readability one volume at a time with immediate space reclamation, resolving historical/tmpexhaustion on long incremental chains. - Dedicated Local vs. Archive Comparison Action (
duplicity compare): Added a dedicated top-levelcomparecommand (aliases:cp,cmp) to compare backup archives against current local files, logging differences across contents, permissions, ownership, and metadata. - Signature-Based Fast Comparison: Validates local file block signatures directly against remote signature chains (
col_stats.get_signature_chain_at_time()), confirming data integrity without downloading multi-gigabyte data volumes or reconstructing past archive versions. - Selective Path Filtering: Extended both
verifyandcomparewith standard--includeand--excludepath filtering for focused verification of specific directory subtrees.
Storage Efficiency, Concurrency & Data Resilience
- Pipelined Concurrency by Default (
--concurrency=1): Concurrency is active by default with 1 pipelined worker process, overlapping frontend filesystem traversal and tar packaging of volume N+1 with background compression, encryption, and network upload of volume N. - Worker-Side Pipelining: Offloaded CPU-intensive encryption, compression (
zstd/zlib-ng/gzip), and cryptographic checksumming from the main process frontend toBackendPoolworker processes via zero-copy IPC streaming (StreamBlockIterandput_volume_stream). - Fast Filesystem Traversal: Replaced recursive
os.lstat()calls withos.scandir()stat caching insrc/selection.py, reused baseTarInfoobjects insrc/diffdir.py, and expanded streaming buffer sizes to 256 KB. - Sparse File Support: Detects, preserves, and restores sparse files efficiently via
--sparseand--no-sparse, utilizing chunked low-level reads (_read_fd) to ensure stream synchronization across Python versions. - Hard Link Preservation: Tracks and restores hard links across backup sets via
--hardlinksand--no-hardlinks, with inode, link count, and permission validation incompare. - Split Metadata Volumes: Supports splitting
.sigtarand.manifestmetadata into bounded volumes adhering to--volsize, eliminating cloud object size limitations on multi-terabyte repositories. - Atomic Backup Completion (
.manifest.complete): Introduced atomic commit markers to guarantee transactional verification and prevent corrupted states caused by interrupted backup sessions. - Aggregate PAR2 Recovery Protection: Overhauled PAR2 protection to cover entire backup sets (data volumes, split signatures, manifests, and completion markers) under aggregate recovery sets with atomic transactional uploads (
Par2Transaction). - Detailed Storage & Timing Statistics: Enhanced statistics reporting (
StatsObj) across CLI outputs and structured JSON (docs/jsonstat_format.rst), trackingSparseFiles,SparseSavings,HardlinkFiles,HardlinkSavings, adjustedNewFileSize, and end-to-endElapsedTime.
CLI Usability, Configuration & Monitoring
- Self-Contained Backend Configuration: Backends in
src/backends/encapsulate their own CLI argument definitions (add_arguments) and URL formats (url_formats), dynamically registered by the CLI parser and decoupling core configuration (src/config.py). - Context-Aware Command Help: Scoped
duplicity <command> --helpstrictly to options valid for the selected action, replacing global--help-<command>options with standard-h/--helparguments. - Always-On Startup Parameter Logging: Automatically records all startup parameters, command-line arguments, and effective configuration settings in execution logs for diagnostic traceability.
- Standardized Logging & Error Codes: Replaced numeric verbosity scales with standard Python logging levels (
DEBUG,INFO,NOTICE,WARNING,ERROR,CRITICAL), single-character shortcuts (d,i,n,w,e,c), and explicit diagnostic error codes. - Real-Time Concurrent Progress Reporting: Synchronized progress reporting across concurrent workers in
BackendPoolusing shared memory counters (multiprocessing.Value). - Cloud Backend Consolidation: Standardized OpenStack Swift and Rackspace Cloud Files access on
python-swiftclient(swift://), retiring deprecated legacy backends (Pyrax,CloudFiles,Hubic).
Key Developer-Oriented & Architectural Improvements
- Pure ctypes librsync Engine (
src/_librsync_ctypes.py): Migrated librsync bindings exclusively to purectypes, completely removing the compiled C extension_librsyncmodule.cand legacysetup.pybuild mechanisms. Enables pure Python wheel builds and effortless cross-platform distribution with recycled buffer pool performance. - Small File Processing Acceleration & Batched IPC: Implemented batched IPC transfers (
put_volume_batch, raw buffer transfers) and streaming prefetching between frontend and backend worker processes, eliminating per-file pipe overhead on directory trees with hundreds of thousands of small files. - Stream-to-Stream Memory Buffer Patching: Implemented callback-driven delta streaming (
rs_patch_beginwith_librsync_py_copy_cb), eliminating intermediate unlinkedtempfile.TemporaryFiledisk writes and reducing storage medium wear. - Modular Codebase Reorganization: Migrated the core source tree from
duplicity/tosrc/and decomposed monolithic workflows fromdup_main.pyinto dedicated modules:src/backup.py: Full and incremental backup pipelines.src/restore.py: Sequential and collated restoration flows with concurrent prefetching.src/cleanup.py: Backup set removal and old volume pruning.src/restart.py: Checkpoint resumption and partial volume recovery.src/sync.py: Remote metadata synchronization.
- JSON Lines Manifest Serialization (v2): Adopted structured JSON Lines (
jsonl) for streaming reads/writes and forward schema extensibility. - BackendPool Worker Lifecycle & Targeted Task Lookup: Extended
BackendPoolwithwait_for_result(track_id)for targeted synchronous completion of asynchronous tasks, along with clean child process termination and SIGINT handling. - Automated Performance Benchmarking Suite (
tools/benchmark.py): Added an automated benchmark framework (benchmark_data.py,benchmark_runner.py,benchmark_report.py) measuring wall-clock time, throughput, CPU utilization, and peak RSS memory across synthetic datasets. - 100% Documentation Coverage: Expanded Sphinx docstrings across all modules, functions, and classes to achieve 100% coverage, detailing signature architecture, rolling checksums,
FileWithSignature, and pipeline dataflows. - Packaging Modernization & Python Support: Modernized packaging under standard
pyproject.toml(PEP 517/PEP 621) with support for Python 3.10 through Python 3.15. - Test Isolation & Parallel Testing: Standardized test fixtures with explicit worker isolation (
testing._runtest_dir,GNUPGHOMEagent isolation, andgpgconf --kill gpg-agentteardowns), enabling reliable multi-core test runs (pytest -n).
Upgrades, Deprecations & Compatibility
- Clean Full Backup Baseline on Legacy Repositories: When writing new backups to a repository created by Duplicity 3.x or older, Duplicity 4.x automatically initiates a clean full backup baseline on first run rather than appending mixed-version delta chains, guaranteeing repository integrity while maintaining full backward-compatible restore and verify capabilities for all historical backup sets.
- Key Deprecations:
duplicity verify --compare-data: Deprecated in favor of the dedicatedduplicity compare(orcp/cmp) action.--path-to-restore: Deprecated in favor of standard positional target arguments and--include/--excludefiltering.- Legacy GnuPG Subprocess Backend: Deprecated in favor of the native AEAD
cryptographybackend, with automatic fallback and transparent command alias support. - Legacy
--help-<command>: Replaced with standardduplicity <command> --helpsyntax.
Resolved Issues
This merge request directly resolves the following upstream tracker issues:
- #14: Fix handling of sparse files during backup and restore.
- #125: Add hard link preservation support across backup archives.
- #254: Standardize command-line argument parsing and remove deprecated wrappers.
- #267: Modularize backend options and isolate backend configuration.
- #788: Resolve process stalls and lock contentions during concurrent GPG operations.
- #853: Provide dedicated command for archive-to-filesystem comparison.
- #884: Support bounded metadata volumes for split signature files.
- #896: Fix
gpgsmlocking and descriptor management on restore operations. - #926: Eliminate compression and encryption bottlenecks with SIMD
zlib-ngand worker pipelining. - #949: Optimize small file processing throughput and reduce IPC overhead.
- #950: Eliminate unbounded temporary disk usage and
/tmpexhaustion during verification. - #951: Implement atomic backup verification markers to avoid corrupted state transitions.
Installation & Getting Started
Duplicity 4.0 development builds can be installed and evaluated via git, package repositories, or PyPI:
# Clone the repository and checkout the latest development release
git clone https://gitlab.com/duplicity/duplicity.git
cd duplicity
git checkout rel.4.0.0.dev12
pip install .
- Launchpad PPA: Duplicity Develop PPA
- Snap Package: Available via the
edge/devchannel:sudo snap install duplicity --classic --edge - Mailing Lists:
duplicity-talk@nongnu.organdduplicity-announce@nongnu.org - Issue Tracker: Duplicity GitLab Issues
- Merge Request Details: GitLab MR !408