Skip to content

Instantly share code, notes, and snippets.

@jreisinger
Created July 19, 2017 06:20
Show Gist options
  • Save jreisinger/e7869300bffa17d806f42dcc2bb92bb8 to your computer and use it in GitHub Desktop.
Save jreisinger/e7869300bffa17d806f42dcc2bb92bb8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import sys, os, subprocess
if len(sys.argv) != 2:
raise SystemExit("Usage: {} USB_MOUNT_POINT".format(sys.argv[0]))
usb_mount_point = sys.argv[1]
home = os.path.expanduser("~")
files = (
os.path.join(home, 'Desktop', 'data'),
os.path.join(home, 'Desktop', 'data2')
)
for f in files:
cmd = [ "rsync", "-az", f, usb_mount_point ]
print(" ".join(cmd), "...", end="")
try:
subprocess.check_output(cmd, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
print(" FAIL")
else:
print(" OK")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment