Skip to content

Commit

Permalink
feat: Updated the if condition with proper context
Browse files Browse the repository at this point in the history
Signed-off-by: Rajesh Rajendran <[email protected]>
  • Loading branch information
rjshrjndrn committed Jul 27, 2020
1 parent 7de7a33 commit a2f77c3
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions deploy/cassandra_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ def copy():
print("Couldn't backup schema, exiting...")
exit(1)
print("Schema backup completed. saved in {}/cassandra_backup/db_schema.sql".format(tmpdir))
# Default value for snapshot
rc = 0

# Creating snapshots
if not args.disablesnapshot:
Expand All @@ -95,17 +93,21 @@ def copy():
# Taking new snapshot
command = "nodetool snapshot -t {}".format(args.snapshotname)
rc = system(command)
if rc == 0:
if not args.disablesnapshot:
print("Snapshot taken.")
copy()
print("Making a tarball: {}.tar.gz".format(args.snapshotname))
command = "cd {} && tar --remove-files -czvf {}/{}.tar.gz *".format(tmpdir, args.tardirectory, args.snapshotname)
rc = system(command)
if rc != 0:
print("Creation of tar failed")
print("Backup failed")
exit(1)
# Cleaning up backup directory
rmtree(tmpdir)
print("Cassandra backup completed and stored in {}/{}.tar.gz".format(args.tardirectory, args.snapshotname))
print("Snapshot taken.")

# Copying the snapshot to proper folder structure
copy()
# Creating tarball
print("Making a tarball: {}.tar.gz".format(args.snapshotname))
command = "cd {} && tar --remove-files -czvf {}/{}.tar.gz *".format(tmpdir, args.tardirectory, args.snapshotname)
rc = system(command)
if rc != 0:
print("Creation of tar failed")
exit(1)
# Cleaning up backup directory
rmtree(tmpdir)
print("Cassandra backup completed and stored in {}/{}.tar.gz".format(args.tardirectory, args.snapshotname))

0 comments on commit a2f77c3

Please sign in to comment.