Last active
December 19, 2015 15:49
-
-
Save johnjosephhorton/5979348 to your computer and use it in GitHub Desktop.
Python backup script to S3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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