Skip to content

Instantly share code, notes, and snippets.

@Disassembler0
Last active March 20, 2019 11:35
Show Gist options
  • Select an option

  • Save Disassembler0/b5627e459fdeb6d44b665a140a52cf1d to your computer and use it in GitHub Desktop.

Select an option

Save Disassembler0/b5627e459fdeb6d44b665a140a52cf1d to your computer and use it in GitHub Desktop.
import os
import sys
import time
### Configuration changes here ###
BACKUP_DIR = "/tmp"
if not AdminConfig.hasChanges():
print "No files were changed. Exiting."
sys.exit(0)
dmgr_profile_path = AdminTask.showVariables(["-scope", "Node="+AdminControl.getNode(), "-variableName", "USER_INSTALL_ROOT"])
if not dmgr_profile_path:
print "Couldn't find Dmgr profile path. Exiting."
sys.exit(1)
changed_files = AdminConfig.queryChanges().splitlines()[1:]
changed_files = [os.path.join(dmgr_profile_path, "config", f.strip()) for f in changed_files]
tar_name = os.path.join(BACKUP_DIR, time.strftime("%Y-%m-%d_%H-%M-%S")+".tgz")
os.system("tar czvf "+tar_name+" "+" ".join(changed_files))
AdminConfig.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment