Skip to content

Instantly share code, notes, and snippets.

@johnjosephhorton
Last active December 19, 2015 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnjosephhorton/5979348 to your computer and use it in GitHub Desktop.
Save johnjosephhorton/5979348 to your computer and use it in GitHub Desktop.
Python backup script to S3
#!/usr/bin/python
# John Horton
import argparse
import sys
import os
parser = argparse.ArgumentParser(description='Make tarball and upload to s3')
parser.add_argument('-d','--dir', help='Input directory',required=True)
args = parser.parse_args()
new_file = args.dir[:-1] + '.tar.gz'
cmd = 'tar -zcvf ' + new_file + " " + args.dir
os.system(cmd)
print("Tarball completed...uploading to S3")
cmd = "s3cmd put " + new_file + " s3://john_horton_backups/"
os.system(cmd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment