diff --git a/deploy/deploy.sh b/deploy/deploy.sh index 577c1c3..dab9c3f 100755 --- a/deploy/deploy.sh +++ b/deploy/deploy.sh @@ -29,7 +29,13 @@ ssh "$HOST" "set -e [ \"\$free\" -ge 3 ] || { echo \"only \${free}G free on /\"; exit 1; } mkdir -p '$SNAPS' if [ -d '$ROOT' ] && [ -n \"\$(ls -A '$ROOT' 2>/dev/null)\" ]; then - cp -al '$ROOT' '$SNAPS/\$(date +%Y%m%d-%H%M%S)' + # Double quotes, not single. Inside single quotes the remote shell never + # expands the command substitution, so every deploy wrote into a single + # directory named after the un-expanded literal, and the SECOND deploy died + # on 'File exists'. It looked like it worked for exactly as long as there + # had only ever been one deploy. Note this comment is inside a + # double-quoted ssh payload: anything it names gets expanded too. + cp -al '$ROOT' \"$SNAPS/\$(date +%Y%m%d-%H%M%S)\" fi ls -1dt '$SNAPS'/*/ 2>/dev/null | tail -n +11 | xargs -r rm -rf"