This set of scripts allow the user to launch periodically restic using PowerShell from a Windows or Linux environment.
Goals:
- Only one script to maintain different systems and OSes (Windows and Linux)
- Do a basic
restichousekeeping:backup,forget,checkpruneis absent as this should be a supervised activityunlockis also absent for the same reason - the backup WILL fail if there's a stall lock
- Avoid backup on metered connection (Windows only)
- One dashboard overview via HealthChecks.io
- Simple enough, so I can understand what's going on
Beware that I'm not a PowerShell expert, I've learned along the way.
I've tested this set of script with PowerShell 7.3 on Windows 10/11, Raspberry Pi OS and Ubuntu Server.
This script can be called periodically to execute restic backup, restic forget and restic check and must have two parameters:
$BackupConfigPath, which is the folder that containscommon_*.ps1andconfig_*.ps1parameters files$BackupConfigName, which is the file name of theconfig_*.ps1file in the$BackupConfigPathwhich has specific parameters for the backup
Example: ./_main_script.ps1 "/home/restic/config" "config_template.ps1"
Can be used when the user needs a restic environment to do other actions.
Parameters are the same than _main_script.ps1.
Example: . ./environment_initialize_CLI_call.ps1 ./config/ config_template.ps1; restic stats
Can be used to start self-update of restic and rclone.
Parameters are /path/to/restic/executable and /path/to/rclone/executable
Example: sudo pwsh ./function_update_CLI_call.ps1 "/opt/restic/restic" "/opt/rclone/rclone"
- Have PowerShell installed: built-in on Windows, see here on Linux
git clonethis repository- Create
log/folder which MUST be in the same folder than the main script - Rename and/or move the
config_templates/to build your ownconfig/folder.- The config folder MUST contain
common.ps1 - The config folder MUST contain
common_windows.ps1orcommon_linux.ps1 - The config folder MUST contain the script that will be called in
$BackupConfigName
- The config folder MUST contain
- If you use
rclone, set-upcommon.ps1with eitherrclone.confor environment variables for your own configuration - Set-up
common_windows.ps1orcommon_unix.ps1with the path toresticandrclone. - Set-up
config_template.ps1for your own configuration- Set up backup source, target, password, …
- Set up HealthChecks.io
UUIDto monitor backup state and receive logs- 3 Checks are required, one for each
resticphase - Suggested naming convention for each Check:
restic ClientName BackupSource 1-backup,… 2-forget,… 3-check
- 3 Checks are required, one for each
- Call
_main_script.ps1 </path/to/config/folder> <config_name.ps1> - Set up
cronand be happy!