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