Check absolutely slaughter download bandwidth; run them once mothly. Relegated logging to systemd

This commit is contained in:
2023-02-24 11:45:32 +02:00
parent f03573d275
commit 97fb7da9b3

View File

@@ -66,7 +66,6 @@ flags()
}
flags "$@"
source /home/shmick/Scripts/Okiru "$VERBOSE"
logging Kumonoboru
#Defaults
if [[ -z $BWLIMIT ]]; then
export BWLIMIT="0"
@@ -101,9 +100,8 @@ backup(){
if safety "$REPOSITORY"; then
#Run the backup
info "Backing up repository" "$REPOSITORY"
if restic --cache-dir="$RESTIC_CACHE_DIR" -r b2:"$REPOSITORY" backup "$REPOSITORY_PATH" --limit-upload="$BWLIMIT" --limit-download="$BWLIMIT" | tee -a $LOG; then
if restic --cache-dir="$RESTIC_CACHE_DIR" -r b2:"$REPOSITORY" backup "$REPOSITORY_PATH" --limit-upload="$BWLIMIT" --limit-download="$BWLIMIT"; then
ok "$REPOSITORY_PATH" "completed upload to $REPOSITORY."
check "$REPOSITORY"
else
error "$REPOSITORY failed to upload path" "$REPOSITORY_PATH"
fi
@@ -120,7 +118,7 @@ check(){
fi
if safety "$REPOSITORY"; then
info "Checking repository health - " "$REPOSITORY"
if restic -r b2:"$REPOSITORY" check --limit-upload="$BWLIMIT" --limit-download="$BWLIMIT" | tee -a $LOG; then
if restic -r b2:"$REPOSITORY" check --limit-upload="$BWLIMIT" --limit-download="$BWLIMIT"; then
ok "Repository passed integrity check - " "$REPOSITORY"
info "Current snapshots:"
restic -r b2:"$REPOSITORY" snapshots | tee -a $LOG
@@ -133,7 +131,7 @@ clean(){
REPOSITORY="$1"
if safety "$REPOSITORY"; then
info "Cleaning repository" "$REPOSITORY"
if restic -r b2:$REPOSITORY forget --keep-daily 7 --keep-weekly 4 --keep-monthly 12 --prune --limit-upload="$BWLIMIT" --limit-download="$BWLIMIT" | tee -a $LOG; then
if restic -r b2:$REPOSITORY forget --keep-daily 7 --keep-weekly 4 --keep-monthly 12 --prune --limit-upload="$BWLIMIT" --limit-download="$BWLIMIT"; then
ok "Repository is trim - " "$REPOSITORY"
debug "Running post clean check..."
check "$REPOSITORY" "1"
@@ -167,12 +165,15 @@ elif [[ -z $CLEAN ]]; then
elif [[ -n $REPOSITORY ]] && [[ -n $CLEAN ]]; then
case "$REPOSITORY" in
(Gerbil-TK)
check Gerbil-TK
clean Gerbil-TK
;;
(Pukeko-XYZ-Containers)
check Pukeko-XYZ-Containers
clean Pukeko-XYZ-Containers
;;
(Pukeko-XYZ-Cloud)
check Pukeko-XYZ-Cloud
clean Pukeko-XYZ-Cloud
;;
(*)
@@ -180,11 +181,13 @@ elif [[ -n $REPOSITORY ]] && [[ -n $CLEAN ]]; then
esac
#If cleaning was forced, or if it's the first of this month - clean.
elif [[ -n $CLEAN ]] || [[ $(date +%d) == "1" ]]; then
check Gerbil-TK
clean Gerbil-TK
check Pukeko-XYZ-Containers
clean Pukeko-XYZ-Containers
check Pukeko-XYZ-Cloud
clean Pukeko-XYZ-Cloud
fi
#Wrap up this run's log and report nicely
echo "All done; have a nice day!"
end_logging
exit 0