Updated to version 2.0.1

- Modified to save all files to a folder tree for backup rather than creating a single monolithic archive.  This will allow restic to properly manage snapshots.
- Changed exception lookup to case-insensitive
This commit is contained in:
ackitsme committed 2026-10-18 12:26:59 -07:00
1 parent e79d26435b
commit 0e07c9ec97
1 file changed
+19 -12
+19 -12
View File
@@ -3,8 +3,8 @@
### Docker Stack Backup Script
### Created by Charlie Silverman - ackitsme3@gmail.com
###############################################################################
### Version: 1.1.3
### Updated: 2026-08-05
### Version: 2.0.1
### Updated: 2026-10-18
### Purpose: Backs up all docker stacks in a given directory to Restic bucket
###############################################################################
### Requirements:
@@ -25,6 +25,10 @@
# 1.1.1 - Added snapshot size to log
# 1.1.2 - Added aggregate backup size to end of log
# 1.1.3 - Added GiB to total backup size information
# 2.0.0 - Modified to save all files to a folder tree for backup rather than
# creating a single monolithic archive. This will allow restic to
# properly manage snapshots
# 2.0.1 - Changed exception lookup to case-insensitive
set -Eeuo pipefail
@@ -68,12 +72,16 @@ log() {
should_skip() {
local project="$1"
shopt -s nocasematch
for pattern in "${SKIP_PROJECTS[@]}"; do
if [[ "$project" == $pattern ]]; then
return 0
fi
done
shopt -u nocasematch
return 1
}
@@ -148,7 +156,7 @@ for compose_file in "${COMPOSE_FILES[@]}"; do
log "Compose file: ${compose_file}"
log "=================================================="
STAGING_DIR="/tmp/docker-backup-${project_name}-${TIMESTAMP}"
STAGING_DIR="/home/Backups/docker-backup-${project_name}"
mkdir -p \
"${STAGING_DIR}/images" \
@@ -197,12 +205,12 @@ for compose_file in "${COMPOSE_FILES[@]}"; do
# Backup Compose Files
###################################################
log "Backing up compose files..."
log "Backing up compose files..."
mkdir -p "${STAGING_DIR}/compose"
tar -czf \
"${STAGING_DIR}/${project_name}-compose.tar.gz" \
-C "$(dirname "$compose_dir")" \
"$(basename "$compose_dir")"
cp -a \
"${compose_dir}" \
"${STAGING_DIR}/compose/"
###################################################
# Backup Images
@@ -220,9 +228,8 @@ for compose_file in "${COMPOSE_FILES[@]}"; do
log "Saving image: $image"
docker save "$image" \
| gzip \
> "${STAGING_DIR}/images/${safe_name}.tar.gz"
docker save "$image" \
> "${STAGING_DIR}/images/${safe_name}.tar"
fi
done < "${STAGING_DIR}/metadata/images.list"
@@ -243,7 +250,7 @@ for compose_file in "${COMPOSE_FILES[@]}"; do
-v "${volume}:/source:ro" \
-v "${STAGING_DIR}/volumes:/backup" \
alpine \
tar -czf "/backup/${volume}.tar.gz" -C /source .
sh -c "cd /source && tar cf - . | tar xf - -C /backup"
done < "${STAGING_DIR}/metadata/volumes.list"