#!/bin/bash # Configuration LOCAL_PATH="./dist/" REMOTE_USER="your_user" REMOTE_HOST="your_server_ip" REMOTE_PATH="/var/www/html/" # Ensure the local path exists if [ ! -d "$LOCAL_PATH" ]; then echo "Error: Local path '$LOCAL_PATH' does not exist." exit 1 fi echo "Starting deployment to $REMOTE_HOST:$REMOTE_PATH..." # Use rsync for efficient synchronization # -avz: Archive mode, verbose, compress # --delete: Delete extraneous files from dest (if you want exact mirror) # --exclude: Exclude specific files/directories (e.g., node_modules, .git) # --progress: Show progress during transfer rsync -avz --delete --exclude 'node_modules/' --exclude '.git/' --progress "$LOCAL_PATH" "$REMOTE_USER@$REMOTE_HOST:$REMOTE_PATH" if [ $? -eq 0 ]; then echo "Deployment successful!" else echo "Deployment failed." exit 1 fi