restic script fixes
This commit is contained in:
parent
27e305a6ec
commit
91bd92045e
@ -1,10 +1,20 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
SERVICE=minecraft.service
|
SERVICE=minecraft.service
|
||||||
VAR_DIR=/opt/minecraft/var
|
VAR_DIR=/opt/minecraft/var
|
||||||
WAIT=30
|
WAIT=30
|
||||||
VERBOSE=${VERBOSE:-4}
|
VERBOSE=${VERBOSE:-4}
|
||||||
|
|
||||||
|
prereq() {
|
||||||
|
local service=$1
|
||||||
|
if ! systemctl list-units --full --all | grep -Fq "$service"; then
|
||||||
|
printf "%s unit does not exit\n" "$service"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
error_exit() {
|
error_exit() {
|
||||||
printf "%s\n" "$1" >&2
|
printf "%s\n" "$1" >&2
|
||||||
exit 1
|
exit 1
|
||||||
@ -75,6 +85,8 @@ open_files() {
|
|||||||
|
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
prereq "$SERVICE"
|
||||||
|
|
||||||
if [ "$1" == "pre" ]; then
|
if [ "$1" == "pre" ]; then
|
||||||
printf "stopping %s\n" $SERVICE
|
printf "stopping %s\n" $SERVICE
|
||||||
if ! stop_server $SERVICE; then
|
if ! stop_server $SERVICE; then
|
||||||
|
@ -64,6 +64,7 @@ counter=0
|
|||||||
sleep=1
|
sleep=1
|
||||||
rc=1
|
rc=1
|
||||||
|
|
||||||
|
printf "restic started\n"
|
||||||
until [ $counter -eq "$MAX_ATTEMPTS" ] || [ $rc -eq 0 ]; do
|
until [ $counter -eq "$MAX_ATTEMPTS" ] || [ $rc -eq 0 ]; do
|
||||||
if [ -r "$EXCLUDE_PATH" ]; then
|
if [ -r "$EXCLUDE_PATH" ]; then
|
||||||
$NICE "$RESTIC_PATH" backup -q --exclude-file="${EXCLUDE_PATH}" "${PATHS}"
|
$NICE "$RESTIC_PATH" backup -q --exclude-file="${EXCLUDE_PATH}" "${PATHS}"
|
||||||
@ -81,6 +82,7 @@ until [ $counter -eq "$MAX_ATTEMPTS" ] || [ $rc -eq 0 ]; do
|
|||||||
|
|
||||||
(( counter++ ))
|
(( counter++ ))
|
||||||
done
|
done
|
||||||
|
printf "restic complete\n"
|
||||||
|
|
||||||
if [ $rc -ne 0 ] && [ $counter -eq "$MAX_ATTEMPTS" ]; then
|
if [ $rc -ne 0 ] && [ $counter -eq "$MAX_ATTEMPTS" ]; then
|
||||||
printf "restic job timed out, exiting\n"
|
printf "restic job timed out, exiting\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user