48 wiersze
1.4 KiB
Python
48 wiersze
1.4 KiB
Python
from python_on_whales import docker
|
|
import datetime
|
|
import sys
|
|
import pathlib
|
|
import yaml
|
|
import collections.abc
|
|
|
|
def update(orig_dict, new_dict):
|
|
for key, val in new_dict.items():
|
|
if isinstance(val, collections.abc.Mapping):
|
|
tmp = update(orig_dict.get(key, { }), val)
|
|
orig_dict[key] = tmp
|
|
elif isinstance(val, list):
|
|
orig_dict[key] = (orig_dict.get(key, []) + val)
|
|
else:
|
|
orig_dict[key] = new_dict[key]
|
|
return orig_dict
|
|
|
|
now = "{date:%Y%m%d-%H%M%S}".format( date=datetime.datetime.now() )
|
|
|
|
source_volume = "friendica_db"
|
|
archive_filename = source_volume + "-" + now
|
|
archive_bind = pathlib.Path().resolve()
|
|
archive_path = str(archive_bind) + "/" + archive_filename
|
|
|
|
image = "loomchild/volume-backup"
|
|
command = ["backup",
|
|
"-c", "gz",
|
|
archive_filename]
|
|
volumes = [ (source_volume,"/volume"),
|
|
(archive_bind, "/backup") ]
|
|
|
|
print("Archive volume: ", source_volume, " to file: ", archive_path)
|
|
|
|
#out=docker.run(image=image,
|
|
# command=command,
|
|
# volumes=volumes)
|
|
|
|
with open("config.yml", mode="rt", encoding="utf-8") as file:
|
|
config = yaml.safe_load(file)
|
|
print(config)
|
|
with open("config-default.yml", mode="rt", encoding="utf-8") as file:
|
|
config_default = yaml.safe_load(file)
|
|
print(config_default)
|
|
|
|
config = update(config_default, config)
|
|
print(config)
|