2
0
Fork 0

various changes

main
Ducky 2022-02-23 05:28:53 +00:00
parent 179b37db42
commit dc0f2aa433
1 changed files with 36 additions and 3 deletions

View File

@ -6,6 +6,21 @@ root_dir="$base_dir/../../.."
[[ -z $env_dir ]] && env_dir="/var/zio-backup"
function restic_exec() {
command="$1"
args="${@:2}"
if [[ -z $command ]]; then
say_warn "No command specified. Not running."
else
restic \
--cleanup-cache \
--password-file "$passwd_file" \
--repo "$repo" \
$command `[[ -s $args ]] && echo "$args"`
fi
}
function backup() {
path="$1"
tag="$2"
@ -16,9 +31,11 @@ function backup() {
else
tag="$host_$tag"
restic \
restic_exec \
backup \
--iexclude "__MACOSX" \
--iexclude ".cache" \
--iexclude ".DS_Store" \
--iexclude "cache" \
--iexclude "CachedData" \
--iexclude "CachedExtensionVSIXs" \
@ -27,16 +44,27 @@ function backup() {
--iexclude "GrSharedCache" \
--iexclude "ShaderCache" \
--iexclude "system-cache" \
--iexclude "thumbs.db" \
--iexclude "tmp" \
--exclude-if-present ".nobackup" \
--host "$host" \
--password-file "$passwd_file" \
--repo "$repo" \
--tag "$tag" \
`[[ -s $args ]] && echo "$args"` "$path"
fi
}
function forget() {
tag="$1"
tag="$host_$tag"
restic_exec \
forget \
--host "$host" \
--keep-last 5 \
--tag "$tag"
}
function get_prop() {
file=$1
item=$2
@ -117,3 +145,8 @@ if [[ ! -z $post_script ]]; then
say_do "Executing post-backup script..."
. $post_script
fi
say_do "Removing old backups..."
forget config
forget store
forget variable