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
restic
housekeeping:backup
,forget
,check
prune
is absent as this should be a supervised activityunlock
is 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_*.ps1
andconfig_*.ps1
parameters files$BackupConfigName
, which is the file name of theconfig_*.ps1
file in the$BackupConfigPath
which 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 clone
this 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.ps1
orcommon_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.ps1
with eitherrclone.conf
or environment variables for your own configuration - Set-up
common_windows.ps1
orcommon_unix.ps1
with the path torestic
andrclone
. - Set-up
config_template.ps1
for your own configuration- Set up backup source, target, password, …
- Set up HealthChecks.io
UUID
to monitor backup state and receive logs- 3 Checks are required, one for each
restic
phase - 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
cron
and be happy!