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" [[ -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() { function backup() {
path="$1" path="$1"
tag="$2" tag="$2"
@ -16,9 +31,11 @@ function backup() {
else else
tag="$host_$tag" tag="$host_$tag"
restic \ restic_exec \
backup \ backup \
--iexclude "__MACOSX" \
--iexclude ".cache" \ --iexclude ".cache" \
--iexclude ".DS_Store" \
--iexclude "cache" \ --iexclude "cache" \
--iexclude "CachedData" \ --iexclude "CachedData" \
--iexclude "CachedExtensionVSIXs" \ --iexclude "CachedExtensionVSIXs" \
@ -27,16 +44,27 @@ function backup() {
--iexclude "GrSharedCache" \ --iexclude "GrSharedCache" \
--iexclude "ShaderCache" \ --iexclude "ShaderCache" \
--iexclude "system-cache" \ --iexclude "system-cache" \
--iexclude "thumbs.db" \
--iexclude "tmp" \ --iexclude "tmp" \
--exclude-if-present ".nobackup" \ --exclude-if-present ".nobackup" \
--host "$host" \ --host "$host" \
--password-file "$passwd_file" \
--repo "$repo" \
--tag "$tag" \ --tag "$tag" \
`[[ -s $args ]] && echo "$args"` "$path" `[[ -s $args ]] && echo "$args"` "$path"
fi fi
} }
function forget() {
tag="$1"
tag="$host_$tag"
restic_exec \
forget \
--host "$host" \
--keep-last 5 \
--tag "$tag"
}
function get_prop() { function get_prop() {
file=$1 file=$1
item=$2 item=$2
@ -117,3 +145,8 @@ if [[ ! -z $post_script ]]; then
say_do "Executing post-backup script..." say_do "Executing post-backup script..."
. $post_script . $post_script
fi fi
say_do "Removing old backups..."
forget config
forget store
forget variable