8000 GitHub - djdarcy/preserve: Preserve is a lightweight cross-platform file "preservation" tool that maintains directory structure during file transfers. Includes path normalization (relative/absolute/flat), SHA256 verification, metadata retention, and bidirectional operations. Perfect for archiving, backups, and transferring files while maintaining their original organization.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Preserve is a lightweight cross-platform file "preservation" tool that maintains directory structure during file transfers. Includes path normalization (relative/absolute/flat), SHA256 verification, metadata retention, and bidirectional operations. Perfect for archiving, backups, and transferring files while maintaining their original organization.

License

Notifications You must be signed in to change notification settings

djdarcy/preserve

Repository files navigation

Preserve (v0.2.1)

A cross-platform file preservation tool with path normalization and verification.

Version

Features

  • 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)
  • 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

Installation

pip install preserve

For full functionality on Windows, install with the Windows extras:

pip install preserve[windows]

For dazzlelink integration:

pip install preserve[dazzlelink]

Usage

Basic Usage

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

Path Preservation Options

  • --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

Other Options

  • --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.

Recommended Workflow

For critical data, it's recommended to follow a secure multi-step workflow:

  1. Pre-Verification: Analyze and hash source files
  2. Copy with Structure: Use --rel --includeBase to maintain directory structure
  3. Post-Copy Verification: Verify all files match their source
  4. Test Restoration: Run --dry-run to confirm restore will work
  5. Source Cleanup: Only remove originals after verification passes

See the documentation for more details on secure workflows.

What's New in v0.2.1

  • 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

What's New in v0.2.0

  • 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

License

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/.

About

Preserve is a lightweight cross-platform file "preservation" tool that maintains directory structure during file transfers. Includes path normalization (relative/absolute/flat), SHA256 verification, metadata retention, and bidirectional operations. Perfect for archiving, backups, and transferring files while maintaining their original organization.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

  •  

Packages

No packages published
0