A cross-platform file preservation tool with path normalization and verification.
- Path Preservation: Copy or move files with multiple path preservation styles:
- Relative paths that maintain directory structure (
--rel
) - Absolute paths with drive letter preservation (
--abs
) - Flat structure with all files in one directory (
--flat
)
- Relative paths that maintain directory structure (
- Verification: File integrity verification with multiple hash algorithms (MD5, SHA1, SHA256, SHA512)
- Metadata: Preserve file attributes (timestamps, permissions, etc.)
- Manifests: Detailed operation tracking for auditing and reversibility
- Restoration: Restore files to their original locations with verification
- DazzleLink: Optional integration with dazzlelink for enhanced metadata storage and file references
- Cross-Platform: Works on Windows, Linux, and macOS
pip install preserve
For full functionality on Windows, install with the Windows extras:
pip install preserve[windows]
For dazzlelink integration:
pip install preserve[dazzlelink]
Copy files with relative path preservation (from a file list):
preserve COPY --loadIncludes "files-to-copy.txt" --dst "e:/backup" --rel --dazzlelink --includeBase
Or (search the source directory for files):,
preserve COPY --glob "*.txt" --srchPath "c:/data" --rel --dst "e:/backup"
Move files with absolute path preservation:
preserve MOVE --glob "*.docx" --srchPath "c:/old" --abs --dst "d:/new"
Verify files against their source:
preserve VERIFY --src "c:/original" --dst "e:/backup" --hash SHA256
Restore files to their original locations:
preserve RESTORE --src "e:/backup" --force
--rel
: Preserve relative paths--abs
: Preserve absolute paths (with drive letter as directory)--flat
: Flatten directory structure (all files in destination root)--includeBase
: Include base directory name in destination path
--hash
: Specify hash algorithm(s) for verification (MD5, SHA1, SHA256, SHA512)--verify
: Verify files after operation--dazzlelink
: Create dazzlelinks to original files--dry-run
: Show what would be done without making changes--overwrite
: Overwrite existing files in destination
See preserve --help
for full documentation and examples.
For critical data, it's recommended to follow a secure multi-step workflow:
- Pre-Verification: Analyze and hash source files
- Copy with Structure: Use
--rel --includeBase
to maintain directory structure - Post-Copy Verification: Verify all files match their source
- Test Restoration: Run
--dry-run
to confirm restore will work - Source Cleanup: Only remove originals after verification passes
See the documentation for more details on secure workflows.
- Improved relative path mode fallback behavior: now falls back to absolute path style (preserving structure) instead of flat structure when no common base directory can be found
- Enhanced logging for path resolution to make fallback behavior clearer
- Added test script for relative path fallback scenarios
- Fixed relative path mode (
--rel
) to properly preserve directory structure - Improved path detection and common base directory finding
- Fixed RESTORE operation for all path modes
- Enhanced debugging and error reporting
- Fixed duplicate log messages
- Added verification report generation
preserve, aka preserve.py, Copyright (C) 2025 Dustin Darcy
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.