fix: recover staging deploy tree ownership

This commit is contained in:
Jesse_Chen
2026-07-30 12:18:24 +08:00
parent 31e5709f33
commit 2be454dfcf
2 changed files with 65 additions and 1 deletions
+9 -1
View File
@@ -6,7 +6,15 @@ if [ "$#" -ne 2 ] || [ ! -d "$1" ] || [ ! -d "$2" ]; then
exit 1
fi
rsync -az --delete \
destination_deploy="$2/deploy"
if [ -d "$destination_deploy" ] && [ ! -w "$destination_deploy" ]; then
docker run --rm --network none --read-only --user 0:0 \
--cap-drop ALL --cap-add CHOWN --security-opt no-new-privileges \
-v "$destination_deploy:/destination" postgres:17-alpine \
chown -R "$(id -u):$(id -g)" /destination
fi
rsync -az --delete --no-owner --no-group \
--exclude='/.git/' \
--exclude='/.env*' \
--exclude='/.docker/' \