Guest User

Untitled

a guest
Jan 19th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. # Local-Remote synchronization of directories/files
  2. # NOTE: Deletions are NOT considered yet.
  3.  
  4. # Usage
  5. # -----
  6. # Local-remote sync:
  7. # make -f Makefile.rsync lrsync SERVER=my_host PROJECT=project_name LOCAL_BASEDIR=/Users/my_name/dev REMOTE_BASEDIR=/home/my_name/dev
  8. #
  9. # Remote-local sync:
  10. # make -f Makefile.rsync rlsync SERVER=my_host PROJECT=project_name LOCAL_BASEDIR=/Users/my_name/dev REMOTE_BASEDIR=/home/my_name/dev
  11.  
  12. REMOTE_DIR := $(REMOTE_BASEDIR)/$(PROJECT)
  13. LOCAL_DIR := $(LOCAL_BASEDIR)/$(PROJECT)
  14.  
  15. get-remote-changes:
  16. echo "Creating remote dir ($(REMOTE_DIR)) if it doesn't exist"
  17. ssh -t $(SERVER) "mkdir -p $(REMOTE_DIR)"
  18. rsync -avzru $(SERVER):$(REMOTE_DIR) $(LOCAL_BASEDIR)
  19.  
  20. put-local-changes:
  21. echo "Creating local dir ($(LOCAL_DIR)) if it doesn't exist"
  22. mkdir -p $(LOCAL_DIR)
  23. rsync -avzru $(LOCAL_DIR) $(SERVER):$(REMOTE_BASEDIR)
  24.  
  25. lrsync: put-local-changes get-remote-changes
  26.  
  27. rlsync: get-remote-changes put-local-changes
Add Comment
Please, Sign In to add comment