README file from
GithubObsidian Zstd Backup
A cross-platform, zero-dependency backup plugin for Obsidian that creates compressed, cryptographically verified backups of your vault using tar archiving and Zstandard (ZSTD) compression.
Built entirely in pure TypeScript/JavaScript, this plugin runs inside Obsidian's desktop environment without requiring any external command-line binaries (like tar or zstd) installed on your computer.
🚀 Key Features
-
Pure JS/TS Compression Stack: Uses optimized, in-process JavaScript libraries (
tarandzstdify) to compress your vault, ensuring 100% portability across Windows, macOS, and Linux. -
SHA-256 Integrity Verification: Generates a sidecar
.sha256checksum file for every backup. Before restoring, the plugin automatically validates the archive integrity to protect against silent data corruption. -
Non-Destructive Restoration: Restoration never overwrites your live vault directly. Instead, it extracts the selected backup snapshot into a dedicated, timestamped folder inside your configured recovery directory, allowing you to review files before merging them.
-
Configurable Pruning: Limit the number of backups stored locally to save disk space. Easily set your preferred limit (e.g., keep last 10 backups) using a simple number box in the settings.
-
Simple GUI Controls:
- Left-ribbon icon (left arrow) to open the restoration snapshot list view.
- Settings panel with configuration fields and manual Backup and Restore buttons.
🔒 Why This Plugin is Safe to Use
- No Destructive Overwrites: Restoring a backup does not touch your active vault files. It extracts the files to a separate subdirectory, letting you inspect or retrieve specific files side-by-side without risking your current day's work.
- In-Process execution (No Shell Spawning): Unlike plugins that execute terminal shell commands (which can introduce OS command injection vulnerabilities or fail on pathnames containing spaces), all tar and compression logic runs inside Node.js's safe API layer.
- Checksum Verification: Every backup creates a
.sha256validation file. The restore process reads the checksum and validates the archive content before attempting any decompression, ensuring you never restore corrupted archives. - Excluded Cache/Metadata folders: To keep backups small and clean, system metadata folders like
.obsidian(plugin cache/configs) and.trashare automatically excluded from the archives.
💡 Usecases
- Pre-Refactoring Checkpoint: Creating a quick backup before performing bulk operations like bulk search-and-replace, folder restructurings, or heavy plugin updates.
- Accidental File Recovery: Easily roll back to a prior state of your note or retrieve deleted attachment assets without searching through cloud syncing histories.
- Storage-Efficient Archiving: Zstandard provides significantly better compression ratios and speeds than standard GZIP or ZIP, saving local hard drive space.
⚙️ Configuration
Open Obsidian Settings > Zstd Backup:
- Vault Directory: The absolute path to your active Obsidian vault.
- Backup Directory: The directory where your
.tar.zstand.sha256files will be saved. - Enable Pruning: Toggle on/off the automatic cleanup of older backups.
- Max Backups: A text field to enter the maximum number of archives to retain.
- Manual actions: Click Backup to run an immediate backup, or Restore to view the snapshot recovery panel.
🛠️ Development
If you want to compile and build the plugin locally:
- Clone this repository.
- Run
npm installto install dependencies. - Create a
local.config.jsonfile in the root directory to map your test vault path:{ "targetDir": "/path/to/your/test/vault/.obsidian/plugins/zstd-backup/" } - Run
npm run devto start the watch compiler. - Run
npm run buildto build a production release.
📄 License
This project is licensed under the MIT License.