feat: Updates docker backup script.

This commit is contained in:
2025-04-21 13:40:29 -04:00
parent 649490f7f1
commit c779861eed

View File

@@ -4,8 +4,7 @@ today=$(date +'%F')
stackdir="/etc/komodo/stacks" stackdir="/etc/komodo/stacks"
backupdir="/backups" backupdir="/backups"
services=() services=($(find "$stackdir" -maxdepth 1 -mindepth 1 -type d))
readarray -d '' services < <(find "$stackdir" -maxdepth 1 -mindepth 1 -type d)
# Directories to backup. # Directories to backup.
volumes=( volumes=(
@@ -42,8 +41,10 @@ function copyVolumes() {
mkdir "$dir" mkdir "$dir"
for volume in "${volumes[@]}"; do for volume in "${volumes[@]}"; do
# copy only directories. # copy only directories.
find "$volume" -maxdepth 1 -mindepth 1 -type d -print0 | local dirs=($(find "$volume" -maxdepth 1 -mindepth 1 -type d))
xargs -0 -I {} cp -r --parents "$volume" "{}" for v in "${dirs[@]}"; do
cp -r --parents "$v" "$dir"
done
done done
} }
@@ -58,8 +59,10 @@ function backup() {
function cleanBackups() { function cleanBackups() {
echo "Removing old backups..." echo "Removing old backups..."
# Remove backups older than 7 days. # Remove backups older than 7 days.
find "$backupdir" -maxdepth 1 -mindepth 1 -name "*.tar.gz" -mtime +7 -print0 | local dirs=($(find "$backupdir" -maxdepth 1 -mindepth 1 -name "*.tar.gz" -mtime +7))
xargs -0 -I {} rm -rf "{}" for dir in "${dirs[@]}"; do
rm -rf "$dir"
done
} }
function main() { function main() {