mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup-cleanup.git
synced 2024-11-24 06:31:03 +01:00
Compare commits
3 Commits
2949e09aee
...
7b00a6584b
Author | SHA1 | Date | |
---|---|---|---|
7b00a6584b | |||
87fae0c86c | |||
3cad6aa0bb |
18
cleanup.sh
18
cleanup.sh
@ -4,8 +4,13 @@
|
|||||||
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/backup-docker-to-local"
|
||||||
echo "Checking backup directory: $MAIN_DIRECTORY"
|
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
|
# Define trigger directory argument as TRIGGER_DIR
|
||||||
TRIGGER_DIR="$2"
|
TRIGGER_DIR="$2"
|
||||||
@ -15,8 +20,12 @@ 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
|
||||||
|
echo "Validating directory: $SUBDIR"
|
||||||
# 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
|
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
|
# Display the subdirectory contents
|
||||||
echo "Contents of subdirectory: $SUBDIR"
|
echo "Contents of subdirectory: $SUBDIR"
|
||||||
ls "$SUBDIR"
|
ls "$SUBDIR"
|
||||||
@ -31,7 +40,8 @@ for SUBDIR in "$MAIN_DIRECTORY"/*; do
|
|||||||
rm -vrf "$SUBDIR"
|
rm -vrf "$SUBDIR"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "$SUBDIR contains $TRIGGER_DIR."
|
echo "Validation: ok"
|
||||||
|
echo "$SUBDIR contains $FULL_TRIGGER_DIR_PATH."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user