mirror of
				https://github.com/kevinveenbirkenbach/docker-volume-backup-cleanup.git
				synced 2025-10-31 02:10:51 +00: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" | ||||
|  | ||||
| # 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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user