Skip to content

Instantly share code, notes, and snippets.

@gokusenz
Created July 30, 2019 16:26
Show Gist options
  • Save gokusenz/52c1b841abb259da6eff2b3e0ea59c0c to your computer and use it in GitHub Desktop.
Save gokusenz/52c1b841abb259da6eff2b3e0ea59c0c to your computer and use it in GitHub Desktop.
Rsync example [Python3]
#!/usr/bin/env python
import sys
import os
import re
import subprocess as sub
import requests
def runProcess(exe):
p = sub.Popen(exe, stdout=sub.PIPE, stderr=sub.PIPE)
output, errors = p.communicate()
return output
head = runProcess(['git', 'symbolic-ref', 'HEAD']).strip()
matchObj = re.match('refs/heads/(master)', head.decode("utf-8"))
if matchObj:
print("Sync Master")
os.system("rsync -rloDcv -e 'ssh' . username@[ip-address]:/pathontheserver --exclude=.git --exclude-from=.gitignore --delete")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment