migrate script
This commit is contained in:
parent
d220d2f034
commit
84c33e423b
1 changed files with 50 additions and 8 deletions
|
|
@ -4,7 +4,8 @@
|
|||
# Run this FROM the dev Mac (einszwovier.local) to migrate to production Mac (124.local)
|
||||
#
|
||||
|
||||
set -e # Exit on any error
|
||||
# Don't exit on error - we'll handle retries
|
||||
set +e
|
||||
|
||||
echo "════════════════════════════════════════════════════════════════"
|
||||
echo " Studio EinsZwoVier - Production Migration Script"
|
||||
|
|
@ -29,6 +30,7 @@ fi
|
|||
PROD_MAC="124" # SSH config alias for admin@124.local
|
||||
DEV_PATH="/Users/aron124/webapp_124"
|
||||
PROD_PATH="/Users/admin/webapp_124"
|
||||
MAX_RETRIES=5
|
||||
|
||||
echo ""
|
||||
echo "═══ Step 1: Stop services on dev Mac (locally) ═══"
|
||||
|
|
@ -42,17 +44,57 @@ ssh "$PROD_MAC" "mkdir -p $(dirname "$PROD_PATH")"
|
|||
echo "✅ Directory created"
|
||||
|
||||
echo ""
|
||||
echo "═══ Step 3: Copy all files (this may take 10-30 minutes) ═══"
|
||||
echo "═══ Step 3: Copy all files (auto-resume enabled) ═══"
|
||||
echo "Copying from: $DEV_PATH (local)"
|
||||
echo "Copying to: $PROD_MAC:$PROD_PATH"
|
||||
echo ""
|
||||
|
||||
# Use rsync for better progress and resume capability
|
||||
if command -v rsync &> /dev/null; then
|
||||
rsync -avz --progress "$DEV_PATH/" "$PROD_MAC:$PROD_PATH/"
|
||||
else
|
||||
# Fallback to scp
|
||||
scp -r "$DEV_PATH" "$PROD_MAC:$(dirname "$PROD_PATH")/"
|
||||
# Rsync with auto-retry on failure
|
||||
RETRY_COUNT=0
|
||||
RSYNC_SUCCESS=0
|
||||
|
||||
while [ $RETRY_COUNT -lt $MAX_RETRIES ] && [ $RSYNC_SUCCESS -eq 0 ]; do
|
||||
if [ $RETRY_COUNT -gt 0 ]; then
|
||||
echo ""
|
||||
echo "⚠️ Connection interrupted. Resuming transfer (attempt $((RETRY_COUNT + 1))/$MAX_RETRIES)..."
|
||||
sleep 5
|
||||
fi
|
||||
|
||||
if command -v rsync &> /dev/null; then
|
||||
# Rsync with:
|
||||
# -a: archive mode
|
||||
# -v: verbose
|
||||
# --progress: show progress
|
||||
# --partial: keep partially transferred files
|
||||
# --append-verify: resume from where we left off
|
||||
# --timeout=300: 5min timeout per operation
|
||||
# --compress-level=0: no compression (faster for local network)
|
||||
rsync -av --progress --partial --append-verify --timeout=300 --compress-level=0 \
|
||||
--no-inc-recursive "$DEV_PATH/" "$PROD_MAC:$PROD_PATH/"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
RSYNC_SUCCESS=1
|
||||
else
|
||||
RETRY_COUNT=$((RETRY_COUNT + 1))
|
||||
fi
|
||||
else
|
||||
# Fallback to scp with keep-alive
|
||||
scp -o ServerAliveInterval=60 -o ServerAliveCountMax=10 -r "$DEV_PATH" "$PROD_MAC:$(dirname "$PROD_PATH")/"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
RSYNC_SUCCESS=1
|
||||
else
|
||||
RETRY_COUNT=$((RETRY_COUNT + 1))
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $RSYNC_SUCCESS -eq 0 ]; then
|
||||
echo ""
|
||||
echo "❌ Failed to transfer files after $MAX_RETRIES attempts."
|
||||
echo "You can manually resume with:"
|
||||
echo " rsync -av --progress --partial --append-verify $DEV_PATH/ $PROD_MAC:$PROD_PATH/"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Files copied successfully"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue