Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #/bin/bash
- Remote='domain:/var/www/htdocs/'
- Local='/Users/user/programming/websites/server-domain/'
- function are_you_sure {
- read -p "Run this command (y/n)?"
- if [ "$REPLY" != "y" ]; then
- echo "Aborting."
- exit 1
- fi
- }
- if [ "$#" = "2" ]; then
- if [ "$2" = "--no-check" ]; then
- echo "Skip run"
- DryRun=0
- else
- DryRun=1
- fi
- else
- DryRun=1
- fi
- case "$1" in
- push)
- echo " Pushing files to remote server"
- if [ "$DryRun" = "1" ]; then
- echo "Executing dry run"
- rsync -azvn -e "ssh" --delete $Local $Remote
- are_you_sure
- fi
- rsync -azv -e "ssh" --delete $Local $Remote
- ;;
- pull)
- echo " Pulling files to remote server"
- if [ "$DryRun" = "1" ]; then
- echo "Executing dry run"
- rsync -azvn -e "ssh" --delete $Remote $Local
- are_you_sure
- fi
- rsync -azv -e "ssh" --delete $Remote $Local
- ;;
- *)
- echo "Commands: push, pull with --no-check as an option."
- ;;
- esac
Add Comment
Please, Sign In to add comment