diff --git a/backup.sh b/backup.sh index e20daa7..709964b 100755 --- a/backup.sh +++ b/backup.sh @@ -72,6 +72,8 @@ else fi if [[ \ $*\ != *\ --skip-backup\ * ]]; then + rm -rf "${backup_path}" + for service in "${services[@]}"; do echo "service: $service" details=$(docker service inspect "$service" --format "{{ json .Spec.Labels }}") @@ -100,7 +102,7 @@ if [[ \ $*\ != *\ --skip-backup\ * ]]; then # creates the parent folder, so `docker cp` has reliable behaviour no matter if $p ends with `/` or `/.` dir=$backup_path/$service/$(dirname "$p") test -d "$dir" || mkdir -p "$dir" - docker cp "$container:$p" "$dir/$(basename "$p")" + docker cp -a "$container:$p" "$dir/$(basename "$p")" done if [ "$post" != "null" ]; then @@ -122,4 +124,3 @@ if [[ \ $*\ != *\ --skip-upload\ * ]]; then _restic backup --host "$server_name" --tag coop-cloud "$backup_path" fi -rm -rf "${backup_path}" \ No newline at end of file