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 1098ec4 commit 8b76679
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions backup/bareos_pool_operations/batch_process_bareos_volumes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,36 +37,36 @@

# Usage:
#
# # batch_process_bareos_volumes.sh <action> <name_mask> <start> <end> <--force/print>
# ./batch_process_bareos_volumes.sh <action> <name_mask> <start> <end> <force/print> <pool_path_for_dumb>
#
# where: action should be 'prune', 'purge' or 'delete'. Optional you can use: '--force'
# to skip confirmation request or '--print' to get the info about selected range
# of volumes. '--print' will not perform changes in volume status, just output an
# info.
# e.g:
# # batch_process_bareos_volumes.sh delete Incremental- 0032 1200
# where: action should be 'prune', 'purge', 'delete' or 'dumb. Optional you can use: 'force'
# to skip confirmation request or 'print' to get the info about selected range
# of volumes. 'print' will not perform changes in volume status, just output an
# info.
# e.g:
# ./batch_process_bareos_volumes.sh delete Incremental- 0032 1200
#
# when you set 'dumb' action <pool_name_for_dumb> <pool_path_for_dumb> may be specified, e.g.:
# /batch_process_bareos_volumes.sh delete Incremental- 0032 1200 /mnt/backup


# Set up default pool path, e.g.: "/mnt/backup"
DEFAULT_POOL_PATH="/mnt/backup"
# Set up default pool name, e.g. "Full" or "Incremental"
DEFAULT_POOL_NAME="Full"


VOL_ACTION=$1
VOL_MASK=$2
VOL_START=$3
VOL_END=$4
VOL_OPT=$5
VOL_POOL=$6
VOL_PATH=$7
VOL_PATH=$6
OPTIONS_ERROR=0

[[ -z "$VOL_MASK" ]] && echo "Error! <name_mask> is undefined." && OPTIONS_ERROR=1
[[ -z "$VOL_ACTION" ]] && echo "Error! <action> is undefined." && OPTIONS_ERROR=1
[[ -z "$VOL_START" ]] && echo "Error! <start> is undefined." && OPTIONS_ERROR=1
[[ -z "$VOL_END" ]] && echo "Error! <end> is undefined." && OPTIONS_ERROR=1
[[ -z "$VOL_POOL" ]] && VOL_POOL=$DEFAULT_POOL_PATH
[[ -z "$VOL_PATH" ]] && VOL_PATH=$DEFAULT_POOL_NAME
[[ -z "$VOL_PATH" ]] && VOL_PATH=$DEFAULT_POOL_PATH

case $VOL_START in
''|*[!0-9]*) echo "Error! <start> is not a number." && OPTIONS_ERROR=1
Expand All @@ -75,12 +75,11 @@ case $VOL_END in
''|*[!0-9]*) echo "Error! <end> is not a number." && OPTIONS_ERROR=1
esac

if [[ -n "$VOL_OPT" ]]; then
if [[ $VOL_OPT != "force" ]] && [[ $VOL_OPT != "print" ]]; then
echo "Syntax error in additional options: $VOL_OPT" && OPTIONS_ERROR=1
fi
if [[ -n "$VOL_OPT" ]] && [[ $VOL_OPT != "force" ]] && [[ $VOL_OPT != "print" ]]; then
echo "Syntax error in additional options: $VOL_OPT" && OPTIONS_ERROR=1
fi


if [[ $VOL_ACTION != "prune" ]] && [[ $VOL_ACTION != "purge" ]] && [[ $VOL_ACTION != "delete" ]] && \
[[ $VOL_ACTION != "dumb" ]]; then
echo "Syntax error in action option: $VOL_ACTION" && OPTIONS_ERROR=1
Expand All @@ -92,9 +91,8 @@ if [[ $OPTIONS_ERROR -gt 0 ]]; then
printf "%s %s\n" "# ./batch_process_bareos_volumes.sh <action> <name_mask> <start> <end> <force|print>" \
"<pool_name_for_dumb> <pool_path_for_dumb>"
printf "where action: prune|purge|delete|dumb.\n\n"
printf "For dumb action you can also specify pool name (e.g 'Incremental') and pool path (e.g. '/mnt/backup'):\n"
printf "%s %s\n" "# ./batch_process_bareos_volumes.sh <action> <name_mask> <start> <end> <force|print> Incremental" \
"/mnt/backup"
printf "For dumb action you can also specify pool path (e.g. '/mnt/backup'):\n"
printf "# ./batch_process_bareos_volumes.sh <action> <name_mask> <start> <end> <force|print> /mnt/backup\n"
exit 1
fi

Expand All @@ -107,7 +105,7 @@ if [[ $VOL_ACTION == "dumb" ]]; then
for RANGE_ITEM in $(seq -w "$VOL_START" "$VOL_END")
do
RANGE_FILE=file_$RANGE_ITEM.txt
echo "Touch $VOL_POOL-$RANGE_FILE"
echo "Touch $VOL_MASK-$RANGE_FILE"
touch "$VOL_PATH$RANGE_FILE"
done
else
Expand Down

0 comments on commit 8b76679

Please sign in to comment.