first for win

This commit is contained in:
Paul Wilde 2023-01-26 14:32:09 +00:00
parent b2cff6ad68
commit a60c7000e4
6 changed files with 67 additions and 67 deletions

6
.gitignore vendored
View file

@ -1,4 +1,4 @@
env.ps1
exclusions.txt
pre
env.ps1
exclusions.txt
pre
post

View file

@ -1,37 +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
}
$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
}

View file

@ -1,22 +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"
# 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

View file

@ -1,3 +1,3 @@
$dir = Split-Path $script:MyInvocation.MyCommand.Path
. $dir/env.ps1
$dir = Split-Path $script:MyInvocation.MyCommand.Path
. $dir/env.ps1
Invoke-Expression "restic init"

View file

@ -1,2 +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
A set of scripts to simplify running restic backup jobs via scheduler.
Also includes curl resquests to healthchecks.io service for monitoring purposes

View file

@ -1,3 +1,3 @@
$dir = Split-Path $script:MyInvocation.MyCommand.Path
. $dir/env.ps1
$dir = Split-Path $script:MyInvocation.MyCommand.Path
. $dir/env.ps1
Invoke-Expression "restic snapshots"