Skip to main content

Overview

copyparty can detect duplicate files based on their content and avoid storing multiple copies. This saves significant disk space, especially when multiple users upload the same files.

How Deduplication Works

When deduplication is enabled:
  1. File Upload: User uploads a file
  2. Hash Calculation: copyparty calculates the file’s hash (checksum)
  3. Duplicate Check: Compares hash against indexed files
  4. Link Creation: If duplicate found, creates a link instead of copying
The result: only one physical copy exists on disk, with multiple references to it.

Deduplication Methods

copyparty supports three types of deduplication: Symbolic links point to the original file. ✅ Advantages:
  • Each link can have its own timestamp
  • Clearly visible that it’s not a regular file
  • Works on all systems
⚠️ Disadvantages:
  • If you delete the original, symlinks break
  • Some software doesn’t handle symlinks well
  • Renaming files requires copyparty to update links
Hard links are indistinguishable from regular files. ✅ Advantages:
  • Compatible with all software
  • Deleting one copy doesn’t affect others
  • Can be moved/renamed safely with any tool
⚠️ Disadvantages:
  • All copies share the same timestamp
  • Editing one copy modifies all copies
  • Less obvious that deduplication is happening
Reflinks use filesystem-level copy-on-write. ✅ Advantages:
  • Safest option: editing one copy doesn’t affect others
  • Each copy is fully independent
  • Automatic copy-on-write when modified
  • Most space-efficient
⚠️ Disadvantages:
  • Requires Python 3.14+ and Linux kernel 5.3+
  • Limited filesystem support (btrfs, maybe XFS)
  • Not available on ZFS yet

Basic Deduplication Setup

Choosing Deduplication Method

Per-Volume Deduplication

Enable deduplication for specific volumes only:

Cross-Volume Deduplication

Deduplicate files across different volumes:
  • --xlink - Enable cross-volume linking
⚠️ Warning: Cross-volume deduplication is experimental and may have bugs.

Deduplication Statistics

View disk space saved:
Access metrics at:
Metrics include:
  • cpp_dupe_bytes - Disk space saved
  • cpp_dupe_files - Number of duplicate files
  • cpp_vol_bytes - Total volume size
  • cpp_vol_files - Total file count

Advanced Configuration

Safe Deduplication Mode

If you have other software modifying files, use this:
  • --safe-dedup=1 - Verify file integrity before deduplicating
This is slower but prevents deduplication of modified files.

Disable Clone Detection

If using S3 or similar storage where reading is expensive:

Database Location

Move the deduplication database to faster storage:

Skip Hashing for Large Files

Exclude large files from deduplication:
  • Saves indexing time
  • Disables deduplication for matched files
  • Files are still indexed by path/size/date

Deduplication with Uploads

Reject Duplicate Uploads

Prevent users from uploading duplicates:
Without dedup, upload fails if file already exists.
Upload succeeds but creates a link instead of a new copy.

Randomize Duplicate Filenames

Combine with filename randomization:
Uploaders get unique filenames even for duplicate content.

Filesystem Compatibility

Supported on all major filesystems:
  • ext4, ext3, ext2 ✅
  • Btrfs ✅
  • XFS ✅
  • ZFS ✅
  • NTFS ✅
  • exFAT ⚠️ (symlinks may not work)
  • FAT32 ❌ (no symlinks or hardlinks)
Only works on:
  • Btrfs ✅ (fully supported)
  • XFS ⚠️ (maybe, needs testing)
  • ZFS ❌ (not yet, known bugs)
  • ext4/NTFS/others ❌

Example: Complete Deduplication Setup

complete-dedup.conf

Monitoring Deduplication

Calculate Space Savings

Use Prometheus Metrics

Enable metrics and monitor:
Query metrics:
Look for:
  • cpp_dupe_bytes{vol="/"} - Space saved
  • cpp_dupe_files{vol="/"} - Duplicate count

Important Warnings

Do not edit deduplicated files in-place!With symlinks or hardlinks, editing one file edits ALL copies.Safe editing methods:
  • Delete and re-upload
  • Copy the file first, then edit the copy
  • Use an editor that creates a new file (like vim’s “backup” mode)
Database corruption = broken symlinksIf the .hist/up2k.db database becomes corrupted or deleted:
  • Symlinks may point to wrong files
  • Some files may become inaccessible
Prevention:
  • Regular database backups
  • Use --hist to store DB on reliable storage
  • Consider reflinks if your filesystem supports them
Cross-volume deduplication is experimentalThe --xlink option may have bugs. Use at your own risk:
  • Test thoroughly before production use
  • Keep backups
  • Monitor for broken links

Troubleshooting

Check these requirements:
  1. Indexing enabled: -e2dsa or -e2d
  2. Dedup flag set: --dedup or volflag dedup
  3. Database exists: .hist/up2k.db in volume
  4. Files are actually identical (same hash)
Verify with:
The up2k.db database can grow large with many files.Solutions:
  1. Move to SSD: --hist /mnt/ssd/cpp
  2. Exclude large files: nohash: \.(mkv|iso)$
  3. Compress: use XZ filesystem compression
  4. Clean old entries (no built-in tool yet)

Next Steps