From 76c28fdc39a66a72c6ca7f61a3d047510de0e353 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Sun, 31 Dec 2023 17:04:15 +0100 Subject: [PATCH] Added script to cleanup all folders --- cleanup-all.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 cleanup-all.sh diff --git a/cleanup-all.sh b/cleanup-all.sh new file mode 100644 index 0000000..6f5467c --- /dev/null +++ b/cleanup-all.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Get the absolute path of the directory where the current script is located +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + +# Define the path to the original cleanup script using the script directory path +CLEANUP_SCRIPT="$SCRIPT_DIR/cleanup_script.sh" + +# Path to the main directory +MAIN_DIRECTORY="/Backups" + +# Check if the cleanup script exists +if [ ! -f "$CLEANUP_SCRIPT" ]; then + echo "Error: The script $CLEANUP_SCRIPT does not exist." + exit 1 +fi + +# Iterate through each subdirectory in the main directory +for BACKUP_FOLDER_PATH in "$MAIN_DIRECTORY"/*; do + + # Extract the base name (folder name) from the path + BACKUP_FOLDER=$(basename "$BACKUP_FOLDER_PATH") + + # Check if the 'backup-docker-to-local' directory exists + if [ -d "$BACKUP_FOLDER_PATH/backup-docker-to-local" ]; then + echo "Running cleanup script for folder: $BACKUP_FOLDER" + + # Call the cleanup script with just the folder name + "$CLEANUP_SCRIPT" "$BACKUP_FOLDER" + else + echo "Directory $BACKUP_FOLDER_PATH/backup-docker-to-local not found." + fi +done \ No newline at end of file