A high-performance Python tool to compare directories between your SSD/local storage and NAS backup, with advanced caching and optimization features.
- Parallel Processing: Scans source and backup simultaneously using ThreadPoolExecutor
- Intelligent Caching: Stores scan results to avoid re-scanning unchanged directories
- Incremental Scanning: Only scans directories modified since last scan
- Depth Limiting: Control scan depth for faster overview comparisons
- Quick Mode: Optimized preset for fast directory structure comparison
- Missing Backups: Files/directories on source but not on backup
- Outdated Backups: Files that exist but are newer/different on source
- Extra Files: Files only on backup (archived content)
- Matching Files: Properly backed up and up-to-date content
- Full File Scan: Compare individual files (size + modification time)
- Directory-Only Scan: Fast comparison of folder structure only
- Extension Filtering: Focus on specific file types (.mp4, .prproj, etc.)
No installation required - just Python 3.6+ with standard libraries.
python3 check_nas_backup.py "/path/to/source" "/path/to/backup"python3 check_nas_backup.py "/path/to/source" "/path/to/backup" --quick# Directory-only comparison with progress info
python3 check_nas_backup.py "/Volumes/T9" "/Volumes/NAS/Backup" --dirs-only -v
# Incremental scan (only check changed directories)
python3 check_nas_backup.py "/Volumes/T9" "/Volumes/NAS/Backup" --incremental -v
# Focus on specific file types
python3 check_nas_backup.py "/Volumes/T9" "/Volumes/NAS/Backup" --extensions ".mp4,.mov,.prproj"
# Limit scan depth for faster overview
python3 check_nas_backup.py "/Volumes/T9" "/Volumes/NAS/Backup" --max-depth 2 --dirs-only
# Clear cache and do fresh scan
python3 check_nas_backup.py "/Volumes/T9" "/Volumes/NAS/Backup" --clear-cache| Option | Description |
|---|---|
source_dir |
Path to source directory (SSD/local storage) |
backup_dir |
Path to backup directory (NAS/external) |
-v, --verbose |
Show detailed progress and scanning information |
| Option | Description | Default |
|---|---|---|
--quick |
Quick mode: depth-2, dirs-only, cached | Off |
--parallel |
Enable parallel processing | On |
--cache |
Use intelligent caching | On |
--no-cache |
Disable caching completely | Off |
--incremental |
Only scan changed directories | Off |
--clear-cache |
Clear existing cache before scan | Off |
| Option | Description | Default |
|---|---|---|
--dirs-only |
Compare directory structure only | Off |
--max-depth N |
Limit directory scan depth | Unlimited |
--extensions LIST |
Focus on specific file extensions | All files |
π Quick Status Check (recommended for regular use):
python3 check_nas_backup.py "/Volumes/T9" "/Volumes/NAS/Backup" --quick -vβ‘ ~5-30 seconds for most directory structures
π Detailed Project Check:
python3 check_nas_backup.py "/Volumes/T9/ProjectFolder" "/Volumes/NAS/ProjectFolder" --dirs-only -vβ‘ ~10-60 seconds depending on project size
π Full Deep Scan (for comprehensive analysis):
python3 check_nas_backup.py "/Volumes/T9" "/Volumes/NAS/Backup" --incremental -vβ‘ First run: several minutes, subsequent runs: ~30 seconds
π― Media File Focus:
python3 check_nas_backup.py "/Volumes/T9" "/Volumes/NAS/Backup" --extensions ".mp4,.mov,.avi,.mkv" -vThe tool automatically creates cache files in ~/.nas_backup_cache/:
- First scan: Takes longer, builds cache
- Subsequent scans: Much faster using cached data
- Incremental scans: Only check directories modified since last scan
- Clear cache: Use
--clear-cacheto reset and rebuild
π΄ Missing Backups: Critical - These files/directories exist on your SSD but are NOT backed up
Heizkraftwerk/FX6 Day 1/
Project_Files/Important_Document.pdf
π‘ Outdated Backups: Important - Backed up but backup is older than source
Festival_Video/Final_Edit/
Client_Project/Assets/
π΅ Extra Files on NAS: Informational - Files only on backup (archived/deleted from source)
Old_Project_2023/
Archived_Footage/
π’ Matching Files: Good - Properly backed up and current
Current_Project/Source_Files/
Documentation/
- Stores directory scan results with timestamps
- Automatically skips unchanged directories on subsequent runs
- Reduces scan time by 70-90% for repeated operations
- Scans source and backup directories simultaneously
- Uses ThreadPoolExecutor for concurrent file system operations
- Reduces total scan time by ~40-50%
- Only rescans directories with modification time newer than last scan
- Ideal for regular backup status checks
- Can reduce scan time by 80-95% for large, stable directory structures
--max-depth 1: Only top-level directories--max-depth 2: Include one level of subdirectories--max-depth 3: Good balance of detail vs. speed
- Parallel processing enabled by default
- Caching enabled by default
- Quick mode for fastest overview
Slow Performance on Network Drives:
# Use directory-only mode for faster network scans
python3 check_nas_backup.py "/local/path" "/network/path" --dirs-only --max-depth 3Permission Errors:
- Ensure read access to both source and backup directories
- On macOS, may need to grant Terminal full disk access
Out of Memory on Large Directories:
# Use depth limiting and directory-only mode
python3 check_nas_backup.py "/path/source" "/path/backup" --max-depth 2 --dirs-onlyCache Issues:
# Clear cache and rebuild
python3 check_nas_backup.py "/path/source" "/path/backup" --clear-cache- Cache files stored in
~/.nas_backup_cache/ - JSON format with directory timestamps
- MD5 hash-based cache file naming
- Automatic cache invalidation based on directory modification times
- ThreadPoolExecutor with dynamic worker count
- Concurrent source and backup scanning
- Thread-safe progress reporting
- Compares directory
st_mtimewith last scan timestamp - Preserves unchanged directory data from cache
- Only rescans modified directory trees
# Create alias in ~/.zshrc or ~/.bashrc
alias backup-check="python3 ~/path/to/check_nas_backup.py '/Volumes/T9' '/Volumes/NAS/Data 2025' --quick -v"
# Then just run:
backup-check# Check specific project folder
python3 check_nas_backup.py "/Volumes/T9/Stanglwirt" "/Volumes/NAS/Backup/Stanglwirt" --dirs-only -v# Focus on video and image files
python3 check_nas_backup.py "/Volumes/T9" "/Volumes/NAS/Backup" \
--extensions ".mp4,.mov,.avi,.mkv,.jpg,.png,.raw,.dng" -v# Find old files that can be removed from SSD
python3 check_nas_backup.py "/Volumes/T9" "/Volumes/NAS/Archive" --dirs-only -v
# Look at "Extra Files on NAS" section for archived contentTypical performance on modern systems:
| Scenario | Directories | Time (Cold) | Time (Cached) | Time (Incremental) |
|---|---|---|---|---|
| Small project (~100 dirs) | 100 | 2-5s | 0.5-1s | 0.2-0.5s |
| Medium project (~500 dirs) | 500 | 10-30s | 2-5s | 1-2s |
| Large archive (~2000+ dirs) | 2000+ | 2-10min | 10-30s | 5-15s |
Benchmarks assume SSD source and network NAS backup
MIT License - Feel free to modify and distribute.
This is a utility script - feel free to adapt for your specific needs!