mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup-cleanup.git
synced 2024-11-14 18:11:03 +01:00
Update cleanup.sh
This commit is contained in:
parent
2154e42682
commit
c2527c5408
12
cleanup.sh
12
cleanup.sh
@ -4,7 +4,8 @@
|
|||||||
BACKUP_HASH="$1"
|
BACKUP_HASH="$1"
|
||||||
|
|
||||||
# Define main directory containing subdirectories to potentially be deleted
|
# Define main directory containing subdirectories to potentially be deleted
|
||||||
MAIN_DIRECTORY="Backups/$BACKUP_HASH/docker-volume-backup/"
|
MAIN_DIRECTORY="/Backups/$BACKUP_HASH/docker-volume-backup"
|
||||||
|
echo "Checking backup directory: $MAIN_DIRECTORY"
|
||||||
|
|
||||||
# Define trigger directory argument as TRIGGER_DIR
|
# Define trigger directory argument as TRIGGER_DIR
|
||||||
TRIGGER_DIR="$2"
|
TRIGGER_DIR="$2"
|
||||||
@ -14,10 +15,6 @@ for SUBDIR in "$MAIN_DIRECTORY"/*; do
|
|||||||
|
|
||||||
# Only proceed if it is a directory
|
# Only proceed if it is a directory
|
||||||
if [ -d "$SUBDIR" ]; then
|
if [ -d "$SUBDIR" ]; then
|
||||||
|
|
||||||
# Only proceed if the subdirectory name matches a date-time-stamp format (YYYY-MM-DDTHH:MM:SS)
|
|
||||||
if [[ $(basename "$SUBDIR") =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}$ ]]; then
|
|
||||||
|
|
||||||
# Only proceed if the specified trigger directory does not exist within the subdirectory
|
# Only proceed if the specified trigger directory does not exist within the subdirectory
|
||||||
if [ ! -d "$SUBDIR/$TRIGGER_DIR" ]; then
|
if [ ! -d "$SUBDIR/$TRIGGER_DIR" ]; then
|
||||||
# Display the subdirectory contents
|
# Display the subdirectory contents
|
||||||
@ -31,9 +28,10 @@ for SUBDIR in "$MAIN_DIRECTORY"/*; do
|
|||||||
then
|
then
|
||||||
# Notify the user of the deletion, then delete the subdirectory
|
# Notify the user of the deletion, then delete the subdirectory
|
||||||
echo "Deleting subdirectory: $SUBDIR"
|
echo "Deleting subdirectory: $SUBDIR"
|
||||||
rm -rf "$SUBDIR"
|
rm -vrf "$SUBDIR"
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
echo "$SUBDIR contains $TRIGGER_DIR."
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user