Skip to content

Instantly share code, notes, and snippets.

@jfcherng
Created June 4, 2019 19:21
Show Gist options
  • Save jfcherng/955ed2bb8d0ac42197b85fe5740d2c2b to your computer and use it in GitHub Desktop.
Save jfcherng/955ed2bb8d0ac42197b85fe5740d2c2b to your computer and use it in GitHub Desktop.
rsync ssh example
#!/usr/bin/env bash
PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:${PATH}
SERVER_IP="0.0.0.0"
SERVER_PORT="22"
SYNC_DIRS=(
# MySQL
"/usr/local/mysql/bin"
"/usr/local/mysql/lib"
# NGINX
"/usr/local/nginx/sbin"
# Redis
"/usr/local/redis/bin"
# PHP 7.4
"/usr/local/php74/bin"
"/usr/local/php74/sbin"
"/usr/local/php74/lib"
# ImageMagick
"/usr/local/imagemagick"
)
for src_dir in "${SYNC_DIRS[@]}"; do
dest_dir=$(dirname "${src_dir}")
rsync -av --delete -e "ssh -p ${SERVER_PORT}" "root@${SERVER_IP}:${src_dir}" "${dest_dir}"
done
ldconfig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment