Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbazhenoff committed Jan 7, 2024
1 parent e56b379 commit 067f1d8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
8 changes: 4 additions & 4 deletions backup/bareos_pool_operations/clean_expired_bareos_volumes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ process_volume() {
if [[ $MODE == "no" ]]; then
echo "$POOL_ACTION volume=$POOL_PATH$F_NAME yes" | bconsole
# Perform physical delete of file from $POOL_PATH when "--action delete".
# Doesn't matter if this volume is absent in bareos database, this will be removed.
# Doesn't matter if this volume is absent in Bareos database, this will be removed.
if [[ $POOL_ACTION = "delete" ]]; then
echo "Performing physical delete of ${F_NAME} from ${POOL_PATH}..."
rm -f "$POOL_PATH/$F_NAME" && echo "Removed." || echo "${F_NAME} not found."
Expand Down Expand Up @@ -158,19 +158,19 @@ done


printf "%s %s\n" "Performing '${POOL_ACTION}' '${POOL_NAME}' volumes after '${POOL_EXPIRE}' days, filtered by" \
"'${POOL_FILTER}' status... Test mode: '${DRY_RUN}'"
"'${POOL_FILTER}' status... Test mode: '${DRY_RUN}'."
if [[ $POOL_ACTION = "delete" ]] || [[ $POOL_ACTION = "prune" ]] || [[ $POOL_ACTION = "purge" ]]; then
cd $POOL_PATH || exit 1
FILELIST=$(find . -mtime +"$POOL_EXPIRE" -print | grep "$POOL_NAME" | sed 's/[./]//g')
if [[ -z $FILELIST ]]; then
echo "No expired by volumes in $POOL_NAME pool by specified criteria ($POOL_EXPIRE days), nothing to $POOL_ACTION."
printf "%s %s\n" "No expired by volumes in '$POOL_NAME' pool by specified criteria ('$POOL_EXPIRE' days), nothing" \
"to '$POOL_ACTION'."
fi
for FILENAME in $FILELIST
do
# shellcheck disable=SC2012
FILEDATE=$(ls -lh "$FILENAME" | awk '{print $7" "$6" "$8}')
if [[ $POOL_FILTER == "none" ]]; then
echo "filter is none"
process_volume "$FILENAME" "$FILEDATE" "$DRY_RUN"
else
# filter by volume status if $POOL_FILTER is not 'none'
Expand Down
9 changes: 6 additions & 3 deletions backup/bareos_pool_operations/clean_missing_volumes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,17 @@

# Set Pool path, e.g.: /mnt/pool_path
POOL_PATH="/mnt/backup"
# Temporary log of removed files, e.g.: /tmp/removed.log
FILES_LOG="/tmp/removed.log"

cd $POOL_PATH || exit 1
FILELIST=$(find . -maxdepth 1 -type f -printf "%f\n")
[[ -z $FILELIST ]] && echo "Nothing to do."

[[ -z $FILELIST ]] && echo "Nothing to process."
echo "" > $FILES_LOG
for I in $FILELIST; do
echo "list volume=$I" | bconsole | if grep --quiet "No results to list"; then
echo "$I is ready to be deleted"
echo "$I is ready to be deleted" | tee $FILES_LOG
rm -f $POOL_PATH/"$I"
fi
done
[[ -z $(cat $FILES_LOG) ]] && echo "No missing at Bareos database volumes found in '$POOL_PATH', nothing to delete."

0 comments on commit 067f1d8

Please sign in to comment.