Replace backup script with autorestic

This commit is contained in:
Tobias Reisinger 2024-10-06 01:59:46 +02:00
parent 13084e3558
commit ed51a86935
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
17 changed files with 180 additions and 224 deletions

View file

@ -0,0 +1,38 @@
import copy
class FilterModule(object):
def filters(self):
return {
'map_backup_locations': self.map_backup_locations
}
def map_backup_locations(self, locations, backends, hooks):
result = {}
backends_list = list(backends.keys())
for location in locations:
name = location["name"]
new_location = {
"to": backends_list,
"forget": "yes",
"hooks": copy.deepcopy(hooks)
}
if location["type"] == "docker":
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}'")
if location["type"] == "directory":
new_location["from"] = location["path"]
result[name.lower()] = new_location
return result

View file

@ -1,24 +0,0 @@
class FilterModule(object):
def filters(self):
return {
'map_backup_volumes': self.map_backup_volumes,
'map_backup_volumes_service': self.map_backup_volumes_service
}
def map_backup_volumes(self, volumes):
result = {}
for volume in volumes:
result[volume] = {
"external": True,
}
return result
def map_backup_volumes_service(self, volumes):
result = []
for volume in volumes:
result.append("{volume_name}:/backup/volumes/{volume_name}".format(volume_name=volume))
return result