This repository contains a PowerShell workflow that:
- Makes the required modules available: a missing module is installed for the current user with its official installer, and an installed module is updated with its own update command (
Update-DonGrobioneLogging,Update-HiDriveUtility). - Resolves Calibre and backup paths from the HiDrive sync root (via
Get-HiDriveSyncRoot). - Downloads the latest Calibre Portable installer.
- Stops STRATO HiDrive to avoid sync/file-lock issues.
- Creates a split 7z backup of the Calibre Portable folder.
- Installs the update.
- Restarts HiDrive.
- Deletes old backup sets and keeps only the newest configured amount.
If a step fails while HiDrive is stopped, the script restarts HiDrive before it exits.
Calibre Update Backup.ps1Main script for backup, update, HiDrive stop/start, and retention cleanup.
-
Windows PowerShell 5.1
-
Internet access to GitHub, used to install or update the required PowerShell modules on every run:
Both are installed automatically for the current user when they are missing. A failed update is only logged as a warning, and the script continues with the installed version.
-
7-Zip, by default at
%ProgramFiles%\7-Zip\7z.exe -
STRATO HiDrive client, installed and previously synced at least once (so
Get-HiDriveSyncRootcan resolve the sync root from HiDrive logs) -
Calibre Portable located at
<HiDriveSyncRoot>\PortableApps\Calibre Portable, backups written to<HiDriveSyncRoot>\Backup\Calibre -
For running the tests: Pester 3.4 or 4.x (Windows PowerShell 5.1 ships with Pester 3.4.0)
# Run the full workflow with the default settings.
& '.\Calibre Update Backup.ps1'
# Show what would happen without downloading, stopping HiDrive, backing up, installing, or deleting anything.
& '.\Calibre Update Backup.ps1' -WhatIf
# Keep the five newest backup sets and use a different 7-Zip location.
& '.\Calibre Update Backup.ps1' -CalibreBackupRetention 5 -SevenZipPath 'D:\Tools\7-Zip\7z.exe'The script returns exit code 0 on success and 1 on failure, so it can be used from Task Scheduler.
You can also start the script from Windows Explorer with right-click > "Run with PowerShell". If the script fails, the console window stays open until you press Enter, so you can read the error.
Dot-sourcing the script (. '.\Calibre Update Backup.ps1') also runs the full workflow, but it does not set an exit code, so it does not close your PowerShell session.
All settings are script parameters with defaults:
| Parameter | Default | Purpose |
|---|---|---|
-CalibreUpdateSource |
https://calibre-ebook.com/dist/portable |
HTTPS URL of the Calibre Portable installer. |
-SevenZipPath |
%ProgramFiles%\7-Zip\7z.exe |
Full path to 7z.exe. |
-CalibreBackupRetention |
3 |
Number of backup sets to keep (1 to 100). |
- The Calibre and backup paths are derived from
Get-HiDriveSyncRoot, so no hostname-specific configuration is needed. - The installer is downloaded to
$env:TEMP\calibre-portable-installer.exeand deleted after the installation. - Each run writes its own log file to
<Documents>\Logs\Calibre-Update-Backup\<HOSTNAME>_<timestamp>.logvia DonGrobione.Logging, and the five newest log files are kept.
Import-Module Pester -RequiredVersion 3.4.0
Invoke-Pester -Path '.\Tests'The tests mock every destructive or external call, including logging and the module installation, and write only to Pester's TestDrive, so they never touch HiDrive, Calibre, existing backups, or log files. They do not need DonGrobione.Logging or DonGrobione.StratoHiDriveUtils to be installed.
.
|-- Legacy/
| `-- Calibre Update Backup.bat
|-- Tests/
| `-- Calibre Update Backup.Tests.ps1
|-- Calibre Update Backup.ps1
|-- CHANGELOG.md
|-- CLAUDE.md
|-- .gitignore
|-- LICENSE.md
`-- README.md
Legacy/Historical scripts kept for reference only; not actively maintained.Legacy/Calibre Update Backup.batOlder batch-file implementation.Tests/Pester tests, one file per script.Calibre Update Backup.ps1Current maintained script.CHANGELOG.mdVersion history of the script.CLAUDE.mdProject rules, repository memory, and architecture notes for Claude Code..gitignoreGit ignore rules for local/runtime artifacts.LICENSE.mdGNU AGPL v3 license file.README.mdProject documentation.
All files under Legacy/ are retained for reference and migration history. Use Calibre Update Backup.ps1 for current operations.
This project is licensed under the GNU Affero General Public License v3.0. You may use, modify, and distribute it, provided that you make the source code of modified versions available under the same license, including when you offer the software to users over a network.
This project was created with support from AI/KI tooling.