Backing up your Obsidian vault on Windows

Backing up your Obsidian vault on Windows

Published with Share Note 🔸 Part of Obsidian guides

This is a PowerShell script you can use to backup Obsidian. It runs in the background and will zip up an archive of your vault and save it to the specified location.

<#

To add this as a scheduled task, this is the format for the Action page:

Program/script:
cmd

Add arguments:
/c start /min powershell -ExecutionPolicy Bypass -File "C:\Documents\Obsidian\Backup vault.ps1"

#>

$sourceDir = 'C:\Documents\Obsidian';
$targetDir = 'Z:\Backups\'
$targetFilenameBase = 'obsidian_';

$date = get-date;
$dateStr = $date.ToString("yyyy-MM-dd_HHmm");
$targetFile = $targetDir + $targetFilenameBase + $dateStr + '.zip';

Compress-Archive -Path $sourceDir -DestinationPath $targetFile;

Task Scheduler

You need to create a scheduled task in Windows (open the Start Menu and start typing Task Scheduler).

This is what you need to specify for the Action page:

  • Program/script: cmd
  • Add arguments: /c start /min powershell -ExecutionPolicy Bypass -File "C:\Documents\Obsidian\Backup vault.ps1"

Share Note for Obsidian 🌓