Add stage parameter for backup hooks and add immich_upload backup
This commit is contained in:
parent
4db5c1878b
commit
759368b6d6
8 changed files with 49 additions and 11 deletions
|
|
@ -1,5 +1,11 @@
|
|||
import copy
|
||||
|
||||
def hooks_add_or_create(location, key, value):
|
||||
if key in location["hooks"]:
|
||||
location["hooks"][key].append(value)
|
||||
else:
|
||||
location["hooks"][key] = [value]
|
||||
|
||||
class FilterModule(object):
|
||||
def filters(self):
|
||||
return {
|
||||
|
|
@ -22,16 +28,17 @@ class FilterModule(object):
|
|||
if location["type"] == "docker":
|
||||
new_location["from"] = name
|
||||
new_location["type"] = "volume"
|
||||
if location["type"] == "docker_remote":
|
||||
new_location["from"] = name
|
||||
new_location["type"] = "volume"
|
||||
|
||||
if location["type"] == "hook":
|
||||
backup_dir = f"/opt/services/_backup/{name}"
|
||||
new_location["from"] = backup_dir
|
||||
if not "before" in new_location["hooks"]:
|
||||
new_location["hooks"]["before"] = []
|
||||
new_location["hooks"]["before"].append(f"/opt/services/backup/hooks/{name} '{backup_dir}'")
|
||||
|
||||
for hook_type in ["prevalidate", "before", "after", "failure", "success"]:
|
||||
hooks_add_or_create(
|
||||
new_location,
|
||||
hook_type,
|
||||
f"/opt/services/backup/hooks/{name} '{backup_dir}' {hook_type}"
|
||||
)
|
||||
|
||||
if location["type"] == "directory":
|
||||
new_location["from"] = location["path"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue