From 47f1a4d7b4b2c50474d76a691089f5d919854329 Mon Sep 17 00:00:00 2001 From: poduck Date: Wed, 3 Dec 2025 15:51:08 -0500 Subject: [PATCH] fix(deploy): Backup and restore .ssh keys during git-based deployments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- deploy.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/deploy.sh b/deploy.sh index 58ac17a..e9dad38 100755 --- a/deploy.sh +++ b/deploy.sh @@ -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