diff --git a/get_backup b/get_backup index c2f35d5..d2c0fab 100755 --- a/get_backup +++ b/get_backup @@ -22,6 +22,15 @@ def get_backup_dir(backup_name): return backup_path +def handle_head(backup_name): + try: + backup_path = get_backup_dir(backup_name) + start_response(extra_headers=['Content-length: 0']) + except: + start_response(status_code=("404", "Not Found",), extra_headers=['Content-length: 0']) + exit(0) + + def handle_get_rsync(backup_name): """ Prints the absolute path an rsync backup should pull from @@ -67,6 +76,11 @@ def handle_req(): # Should respond by transferring tar.gz data handle_get_archive(params["name"]) + elif os.environ['REQUEST_METHOD'] == "HEAD": + # Respond with 200 or 404 depending if backup exists + # TODO: deeper inspection so the headers can be flushed out + handle_head(params["name"]) + else: raise Exception("Invalid request. Params: %s" % params)