fix docker cp paths
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
Philipp Rothmann 2021-11-24 11:17:13 +01:00
parent f2472bd0d3
commit ce42fb06fd
1 changed files with 11 additions and 8 deletions

View File

@ -95,11 +95,12 @@ if [[ \ $*\ != *\ --skip-backup\ * ]]; then
docker exec "$container" sh -c "$pre"
fi
test -d "$backup_path/$service" || mkdir -p "$backup_path/$service"
# run the backup
for p in ${path//,/ }; do
docker cp "$container:$p" "$backup_path/$service"
# 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")"
done
if [ "$post" != "null" ]; then
@ -120,3 +121,5 @@ fi
if [[ \ $*\ != *\ --skip-upload\ * ]]; then
_restic backup --host "$server_name" --tag coop-cloud "$backup_path"
fi
rm -rf "${backup_path}"