Compare commits
3 Commits
2949e09aee
...
7b00a6584b
Author | SHA1 | Date |
---|---|---|
Kevin Veen-Birkenbach | 7b00a6584b | |
Kevin Veen-Birkenbach | 87fae0c86c | |
Kevin Veen-Birkenbach | 3cad6aa0bb |
18
cleanup.sh
18
cleanup.sh
|
@ -4,8 +4,13 @@
|
|||
BACKUP_HASH="$1"
|
||||
|
||||
# Define main directory containing subdirectories to potentially be deleted
|
||||
MAIN_DIRECTORY="/Backups/$BACKUP_HASH/docker-volume-backup"
|
||||
echo "Checking backup directory: $MAIN_DIRECTORY"
|
||||
MAIN_DIRECTORY="/Backups/$BACKUP_HASH/backup-docker-to-local"
|
||||
if [ -d "$MAIN_DIRECTORY" ]; then
|
||||
echo "Cleaning up directory: $MAIN_DIRECTORY"
|
||||
else
|
||||
echo "Error: $MAIN_DIRECTORY does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Define trigger directory argument as TRIGGER_DIR
|
||||
TRIGGER_DIR="$2"
|
||||
|
@ -15,8 +20,12 @@ for SUBDIR in "$MAIN_DIRECTORY"/*; do
|
|||
|
||||
# Only proceed if it is a directory
|
||||
if [ -d "$SUBDIR" ]; then
|
||||
echo "Validating directory: $SUBDIR"
|
||||
# Only proceed if the specified trigger directory does not exist within the subdirectory
|
||||
if [ ! -d "$SUBDIR/$TRIGGER_DIR" ]; then
|
||||
FULL_TRIGGER_DIR_PATH="$SUBDIR/$TRIGGER_DIR"
|
||||
if [ ! -d "$FULL_TRIGGER_DIR_PATH" ]; then
|
||||
echo "Validation: error"
|
||||
echo "Missing directory: $FULL_TRIGGER_DIR_PATH"
|
||||
# Display the subdirectory contents
|
||||
echo "Contents of subdirectory: $SUBDIR"
|
||||
ls "$SUBDIR"
|
||||
|
@ -31,7 +40,8 @@ for SUBDIR in "$MAIN_DIRECTORY"/*; do
|
|||
rm -vrf "$SUBDIR"
|
||||
fi
|
||||
else
|
||||
echo "$SUBDIR contains $TRIGGER_DIR."
|
||||
echo "Validation: ok"
|
||||
echo "$SUBDIR contains $FULL_TRIGGER_DIR_PATH."
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue