Last active
May 19, 2025 07:17
-
-
Save cco/f5f6155abdd07387ebc04258e0233a6a to your computer and use it in GitHub Desktop.
Powershell script for restic backups using latest winget package for restic. Use task scheduler to automate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $env:RESTIC_REPOSITORY = "" | |
| $env:RESTIC_PASSWORD = "" | |
| $directories = @( | |
| "C:\file\path\", | |
| "\\server\path" | |
| ) | |
| $excludePatterns = @( | |
| "*.mkv", "*.mov", | |
| "*.exe", "*.bin", "*.iso", "*.dll", "*.crdownload", | |
| "*.jpg", "*.jpeg", "*.png", "*.gif", | |
| "C:\file\path\" | |
| ) | |
| $excludeArgs = $excludePatterns | ForEach-Object { "--exclude=$_" } | |
| $backupArgs = @("backup") + $directories + $excludeArgs | |
| Write-Host "Starting restic backup..." -ForegroundColor Cyan | |
| & restic_0.18.0_windows_amd64.exe @backupArgs | |
| Write-Host "Pruning old snapshots..." -ForegroundColor Yellow | |
| & restic_0.18.0_windows_amd64.exe forget --keep-daily 7 --keep-weekly 4 --keep-monthly 1 --prune | |
| Write-Host "Backup completed." -ForegroundColor Green |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment