Provides two simple PowerShell scripts for creating delta updates of directory contents. These scripts identify changes between directory versions and generate an updater package to synchronize them.
Important
Requires PowerShell 7 for .\Create-Checksum.ps1 and .\Generate-DeltaUpdate.ps1 (see Installing PowerShell).
- Generate a checksum file for the original directory using
Create-Checksum.ps1(before changes). - Update, add, or delete files in directory.
- Use
Generate-DeltaUpdate.ps1to compare the modified directory with the original checksum and create an update package (after changes).
Before modifying files, generate a checksum file for the original directory:
.\Create-Checksum.ps1 -Path <TARGET_DIRECTORY> -Output <CHECKSUM_FILE>Note
Depending on directory size, this may take some time.
- Example:
.\Create-Checksum.ps1 -Path "C:/MyApp" -Output "./v1_checksum.txt"
After modifying the directory, create a delta update package:
.\Generate-DeltaUpdate.ps1 -Target <TARGET_DIRECTORY> -Checksum <CHECKSUM_FILE_PATH> -Output <UPDATER_OUTPUT_DIRECTORY>Note
Depending on target directory size, this may take some time.
Tip
You can provide -ShowChangesOnly parameter to only display modified files since last version of the directory (you can't pass -Output parameter with this one).
.\Generate-DeltaUpdate.ps1 -Target <TARGET_DIRECTORY> -Checksum <CHECKSUM_FILE_PATH> -ShowChangesOnly- Example:
.\Generate-DeltaUpdate.ps1 -Target "C:/MyApp" -Checksum "./v1_checksum.csv" -Output "C:/Updates/v1_to_v2"
A <UPDATER_OUTPUT_DIRECTORY> directory would appear (if not already created) containing update.ps1 PowerShell script and data/ directory.
Note
The content of the provided folder is not cleared. You need manually delete it and script will recreate it, otherwise it will overwrite files in it.
The update.ps1 script contains auto generated code to copy data/ into provided in the parameters to script directory and delete removed files since the update.
Run update.ps1 script:
- Open it in File Explorer - a PowerShell window will pop-up with prompt to provided path to directory which needs an update.
- Execute it via PowerShell console with provided
-Pathparameter:.\update.ps1 -Path <TARGET_DIRECTORY>
This will copy data/ contents to target directory and remove files deleted since checksum creation.
The script does not preserve folder, only files (i.e. will not explicitly create/delete directories).
The files in update package are not using delta encoding (i.e. even if a single byte was changed in a file, it will fully stored)
# Create initial checksum
.\Create-Checksum.ps1 -Path C:/MyApp -Output ./v1-checksum.txt
# Update application files (add/modify/delete)
"hello world" > C:/MyApp/file.txt
# Generate update package
.\Generate-DeltaUpdate.ps1 -Target C:/MyApp -Checksum ./v1-checksum.txt -Output v1-to-v2-update
# Apply to v1 installation
.\v2-update\update.ps1 -Path "D:/Production/MyApp"