Skip to content

Instantly share code, notes, and snippets.

@ryujaehun
Created October 15, 2018 04:57
Show Gist options
  • Save ryujaehun/d8803430cddb77819fac380a44b2c6f1 to your computer and use it in GitHub Desktop.
Save ryujaehun/d8803430cddb77819fac380a44b2c6f1 to your computer and use it in GitHub Desktop.
my rsync python script
# /usr/bin/python3
import argparse
import subprocess
import os
parser = argparse.ArgumentParser(description='Jaehun\'s ssh script')
parser.add_argument('--destination','-d', type=str,default='ti', required=False, help="ssh destination")
parser.add_argument('--docker','-o',action='store_true', required=False, help="docker port activation")
parser.add_argument('--file','-f', type=str, required=True, help="file path")
args = parser.parse_args()
destination_list={'dell':'git.deepmi.me', 'ti':'163.180.172.26','v':'163.180.172.118','1':'163.180.118.160','5':'163.180.118.155','6':'163.180.118.156','7':"163.180.118.157"}
port='26022' if args.docker else "16022"
if args.destination=='dell':
port='10022'
if not os.path.exists(args.file):
raise AssertionError("file is not exists!")
if not args.destination in destination_list.keys():
raise AssertionError('destination is wrong!')
if args.destination in ['ti','v','dell'] or args.docker:
user='jaehun'
else:
user='icsl'
proc = subprocess.Popen( "rsync --progress --rsh='ssh -T -o Compression=no -x -p"+port+"' -arvh ~/"+args.file+" "+user +"@"+destination_list[args.destination]+":/home/"+user , shell=True, executable='/bin/bash')
proc.communicate()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment