move rm up, to keep the latest backup in the volume
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
Philipp Rothmann 2021-12-13 11:37:02 +01:00
parent 5a20ef4349
commit d6faffcbbd
1 changed files with 3 additions and 2 deletions

View File

@ -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}"