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