Permalink
Browse files

Update subprocess call for backups.

  • Loading branch information...
barneypotter24 committed Oct 3, 2017
1 parent 26ae998 commit 18892b0648140621e7f1721816d9ba8dfe15d5c1
Showing with 5 additions and 4 deletions.
  1. +5 −4 base/rethink_interact.py
View
@@ -38,8 +38,8 @@ def backup_s3(self, database, path='', delete_expired=False, **kwargs):
for table in tables:
dump_file = self.rethink_io.get_upload_date() + '_' + database + '_' + table + '.tar.gz'
self.dump(database=database, dump_table=table, dump_file=dump_file, **kwargs)
shutil.move(dump_file, path+'/'+dump_file)
bucket.upload_file(path+'/'+dump_file, dump_file)
shutil.move(dump_file, path+'/'+dump_file)
bucket.upload_file(path+'/'+dump_file, dump_file)
print("Successfully backed up")
if delete_expired:
self.delete_expired_s3_backups(bucket, **kwargs)
@@ -71,7 +71,8 @@ def dump(self, database, dump_table, dump_file, rethink_host='localhost', auth_k
command = ['rethinkdb', 'dump', '-e', database + '.' + dump_table, '-f', dump_file]
try:
with open(os.devnull, 'wb') as devnull:
subprocess.check_call(command, stdout=devnull, stderr=subprocess.STDOUT)
print " ".join(command)
subprocess.check_call(command, stdout=devnull, stderr=subprocess.STDOUT, shell=True)
except:
raise Exception("Couldn't dump tar file, make sure " + dump_file + " doesn't exist")
@@ -278,4 +279,4 @@ def write_json(data, file_name, indent=1):
handle.write("\n")
handle.close()
except:
raise Exception("Couldn't write to json " + file_name)
raise Exception("Couldn't write to json " + file_name)

0 comments on commit 18892b0

Please sign in to comment.