fix(deploy): Backup and restore .ssh keys during git-based deployments

SSH keys for mail server management are not in git, need to preserve
them like .envs secrets.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
poduck
2025-12-03 15:51:08 -05:00
parent b455be0ac6
commit 47f1a4d7b4

View File

@@ -83,6 +83,16 @@ elif [ -d "$REMOTE_DIR/.envs" ]; then
cp -r "$REMOTE_DIR/.envs" /tmp/.envs-backup
fi
# Backup .ssh if it exists (SSH keys not in git)
if [ -d "$REMOTE_DIR/smoothschedule/.ssh" ]; then
echo ">>> Backing up .ssh keys..."
cp -r "$REMOTE_DIR/smoothschedule/.ssh" /tmp/.ssh-backup
elif [ -d "$REMOTE_DIR/.ssh" ]; then
# Old structure
echo ">>> Backing up .ssh keys (old location)..."
cp -r "$REMOTE_DIR/.ssh" /tmp/.ssh-backup
fi
if [ ! -d "$REMOTE_DIR/.git" ]; then
echo ">>> Cloning repository for the first time..."
# Remove old non-git deployment if exists
@@ -106,6 +116,13 @@ if [ -d /tmp/.envs-backup ]; then
rm -rf /tmp/.envs-backup
fi
# Restore .ssh keys
if [ -d /tmp/.ssh-backup ]; then
echo ">>> Restoring .ssh keys..."
cp -r /tmp/.ssh-backup "$REMOTE_DIR/smoothschedule/.ssh"
rm -rf /tmp/.ssh-backup
fi
echo ">>> Current commit:"
git log -1 --oneline