Replace backup script with autorestic
This commit is contained in:
parent
13084e3558
commit
ed51a86935
17 changed files with 180 additions and 224 deletions
playbooks/filter_plugins
38
playbooks/filter_plugins/map_backup_locations.py
Normal file
38
playbooks/filter_plugins/map_backup_locations.py
Normal 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
|
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue