first for win
This commit is contained in:
commit
b2cff6ad68
7 changed files with 72 additions and 0 deletions
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
env.ps1
|
||||
exclusions.txt
|
||||
pre
|
||||
post
|
1
backup.bat
Normal file
1
backup.bat
Normal file
|
@ -0,0 +1 @@
|
|||
powershell -File %~dp0/backup.sh
|
37
backup.ps1
Normal file
37
backup.ps1
Normal file
|
@ -0,0 +1,37 @@
|
|||
|
||||
$dir = Split-Path $script:MyInvocation.MyCommand.Path
|
||||
. "$dir/env.ps1"
|
||||
$DATE = (Get-Date).ToString("yyyy-MM-dd HH:mm:ss")
|
||||
Write-Host "Backup $NAME at $DATE"
|
||||
$BACKUP_CMD="restic backup $BACKUP_DIR"
|
||||
if ( $BACKUP_PARAMS ){
|
||||
$BACKUP_CMD="$BACKUP_CMD $BACKUP_PARAMS"
|
||||
}
|
||||
if ( $BACKUP_EXCLUDE_FILE ) {
|
||||
$BACKUP_CMD="$BACKUP_CMD --exclude-file $dir/$BACKUP_EXCLUDE_FILE"
|
||||
}
|
||||
if ( $USE_VSS -eq 1 ) {
|
||||
$BACKUP_CMD = "$BACKUP_CMD --use-windows-vss"
|
||||
}
|
||||
#Write-Host $BACKUP_CMD
|
||||
$running = get-process | ?{$_.path -eq "C:\Windows\system32\restic.exe"}
|
||||
Write-Host $running
|
||||
if ( $running ) {
|
||||
Write-Host "Backup already running; $running. Exiting..."
|
||||
curl https://hc-ping.com/$HEALTHCHECK_UUID/fail
|
||||
exit
|
||||
}
|
||||
Write-Host "Not currently running. Continuing..."
|
||||
curl https://hc-ping.com/$HEALTHCHECK_UUID/start
|
||||
if ( $PRE_RUN_SCRIPT ) {
|
||||
. $dir/$PRE_RUN_SCRIPT
|
||||
}
|
||||
Invoke-Expression $BACKUP_CMD
|
||||
if ( $LastExitCode -eq 0 ) {
|
||||
if ( $POST_RUN_SCRIPT ) {
|
||||
. $dir/$POST_RUN_SCRIPT
|
||||
}
|
||||
curl https://hc-ping.com/$HEALTHCHECK_UUID
|
||||
} else {
|
||||
curl https://hc-ping.com/$HEALTHCHECK_UUID/fail
|
||||
}
|
22
env.sample.ps1
Normal file
22
env.sample.ps1
Normal file
|
@ -0,0 +1,22 @@
|
|||
# Name your backup (only really for logging purposes)
|
||||
$NAME="Backup Name"
|
||||
# The directory to back up
|
||||
$BACKUP_DIR="/dir/to/back/up"
|
||||
# any additional params you want with restic
|
||||
$BACKUP_PARAMS=""
|
||||
# an exclude file, generally I use "exclusions.txt" that's ignored by git
|
||||
$BACKUP_EXCLUDE_FILE=""
|
||||
# https://healthchecks.io uuid
|
||||
$HEALTHCHECK_UUID=""
|
||||
# name of a script to run before (ideally in the "pre/" dir)
|
||||
$PRE_RUN_SCRIPT=""
|
||||
# name of a script to run after (ideally in the "post/" dir)
|
||||
$POST_RUN_SCRIPT=""
|
||||
# Use VSS
|
||||
$USE_VSS = 1
|
||||
|
||||
|
||||
$Env:AWS_ACCESS_KEY_ID=
|
||||
$Env:AWS_SECRET_ACCESS_KEY=
|
||||
$Env:RESTIC_REPOSITORY="s3:https://repo.tld/bucket/sub-bucket"
|
||||
$Env:RESTIC_PASSWORD=V3RYSecuRepaSsWord
|
3
init.ps1
Normal file
3
init.ps1
Normal file
|
@ -0,0 +1,3 @@
|
|||
$dir = Split-Path $script:MyInvocation.MyCommand.Path
|
||||
. $dir/env.ps1
|
||||
Invoke-Expression "restic init"
|
2
readme.md
Normal file
2
readme.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
A set of scripts to simplify running restic backup jobs via scheduler.
|
||||
Also includes curl resquests to healthchecks.io service for monitoring purposes
|
3
snapshots.ps1
Normal file
3
snapshots.ps1
Normal file
|
@ -0,0 +1,3 @@
|
|||
$dir = Split-Path $script:MyInvocation.MyCommand.Path
|
||||
. $dir/env.ps1
|
||||
Invoke-Expression "restic snapshots"
|
Loading…
Reference in a new issue