X-Git-Url: http://gitweb.michael.orlitzky.com/?p=untangle-https-backup.git;a=blobdiff_plain;f=bin%2Funtangle-https-backup;fp=bin%2Funtangle-https-backup;h=dab5c1807bb8e9c712c34d0a184df270f93a15e9;hp=c01c419849f3cb157158146dc464417a523e045d;hb=b76e936f471c7c0c31652056fde8555ab3b913f2;hpb=1b7c4afc84bf55acef350fdc5479e7213c78eaa4 diff --git a/bin/untangle-https-backup b/bin/untangle-https-backup index c01c419..dab5c18 100755 --- a/bin/untangle-https-backup +++ b/bin/untangle-https-backup @@ -29,19 +29,29 @@ args = parser.parse_args() # Default to success, change it if anything fails. status = EXIT_OK +# Parse the configuration file... config = configparser.ConfigParser() config.read(args.config_file) +# And loop through each section. for section in config.sections(): + # For each section, we create an Untangle object based on that + # section's configuration. u = Untangle(config[section]) try: + # And then try to log in and retrieve a backup. u.login() backup = u.get_backup() + + # If that worked, we save the backup file and make it + # accessible only to its owner. filename = u.name + '.backup' with open(filename, 'wb') as f: f.write(backup) chmod(filename, 0o600) + # If it didn't work, but in a predictable way (some host is down), + # then we report that error and keep going. except URLError as e: msg = u.name + ': ' + str(e.reason) + ' from ' + u.host print(msg, file=stderr)