Clones the contents of USB drives and verifies successful duplication
Project description
USB Cloner
USB Cloner is a Python library for rapidly replicating the contents of a USB. It also includes various features to wipe drives before cloning, verify the cloning process, and scramble filenames.
Installation
Use pip to install usbcloner. Python 3.8 or higher is required.
pip3 install usbcloner
Usage
Duplicating USBs
Cloning mode is used to duplicate the contents of one drive to multiple others. Cloning will add files without wiping the drive by default. If there is not enough diskspace, usbcloner will skip the new device and not attempt to clone to it.
# Begin a cloning session using a user-provided USB. Files will be verified using filesizes only--no hashing.
usbcloner
# Wipe all USBs prior to cloning to ensure there is enough disk space and use hashing to verify file duplication for all files.
usbcloner -w -p 100
Verify USB Contents
Verification mode can be used to ensure the contents of numerous devices are identical without performing any cloning.
# Prompt for a USB and verify subsequent USB drives.
usbcloner --verify-only
# Build and save a verification table first, then verify devices using the saved table at a later time.
# Without --verify_only, usbcloner will enter into "cloning" mode after saving the verification table.
usbcloner -o "verify.tbl" --verify_only
# At a later time...
usbcloner -i "verify.tbl" --verify_only
Renaming Files
In addition to duplication and verification, usbcloner allows for the scrambling of filenames on a drive. It does this in a way that maintains the lexicographical (alphabetical sort) order of the files and folders.
# Clone the drives, but scramble the filenames first. All cloned drives will have the same scrambled filenames for the same files.
usbcloner --rename
# Only rename the files that are already on the drive. No cloning or verification.
usbcloner --rename-only
Speed vs Confidence
By default usbcloner only uses filename and file size to verify successful duplication. However, you can use the -p
flag to use hashing to verify duplication for a user-provided percentage of files (0-100).
# Do not perform any hash verification for cloned files. This is the default behavior and the same as running "usbcloner".
usbcloner -p 0
# Perform hash verification for 50% of files after cloning.
usbcloner -p 50
# Perform hash verification for all files after cloning.
usbcloner -p 100
Trim
--trim
removes any files that are found on the drive that are not in the verification table. This is particularly helpful in deleting hidden files that various operating systems add when drives are mounted or viewed. Examples include .DS_Store on OSX and the "System Volume Information" folder on Windows.
usbcloner --trim
Other Examples
Use a folder on disk to clone instead of a user-provided USB.
usbcloner -s ~/Folder_to_be_cloned/
Roadmap
- Add pytest tests
- Add a Rich interface that shows cloning progress in realtime.
- Determine if a drive needs to be reformated
- Test the performance of using Rust for the file copy
- Figure out math on better file name length during renames
- Make it so you don't need to use the computer as a temporary file storage
Ideas
- Figure out how to associate a USB port to a physical port.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file usbcloner-0.1.0.tar.gz
.
File metadata
- Download URL: usbcloner-0.1.0.tar.gz
- Upload date:
- Size: 56.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2e3b9fae625df1ba0875a2d34a10c568dafe44685b5bb8f48c2ea3e4883cbba |
|
MD5 | 1ccd20e740b3a425901f960dc2f2807d |
|
BLAKE2b-256 | ba2bb93f30837112dc193f9922216e632fb219875480b86797c478458433053f |
File details
Details for the file usbcloner-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: usbcloner-0.1.0-py3-none-any.whl
- Upload date:
- Size: 46.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0bdea63eed91213848a18dadec31996c665aa1df4140a735d0fe16369f287232 |
|
MD5 | 7038ee385d634845a1f73775736e361d |
|
BLAKE2b-256 | 2941312b4eb3d854c1dd2f21986def6c113ed9ccc75cf87e6239ecdf27532096 |