mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-09 03:04:54 -04:00
render all templates on auto backup
This commit is contained in:
parent
6e18fcdf76
commit
d229b6c8ef
@ -20,7 +20,11 @@ def auto_backup_job():
|
|||||||
for backup in BACKUP_DIR.glob("Auto*.zip"):
|
for backup in BACKUP_DIR.glob("Auto*.zip"):
|
||||||
backup.unlink()
|
backup.unlink()
|
||||||
|
|
||||||
export_db(tag="Auto", template=None)
|
templates = []
|
||||||
|
for template in TEMPLATE_DIR.iterdir():
|
||||||
|
templates.append(template)
|
||||||
|
|
||||||
|
export_db(tag="Auto", templates=templates)
|
||||||
logger.info("Auto Backup Called")
|
logger.info("Auto Backup Called")
|
||||||
|
|
||||||
|
|
||||||
@ -56,7 +60,7 @@ def import_from_archive(file_name: str) -> list:
|
|||||||
return successful_imports
|
return successful_imports
|
||||||
|
|
||||||
|
|
||||||
def export_db(tag=None, template=None):
|
def export_db(tag=None, templates=None):
|
||||||
if tag:
|
if tag:
|
||||||
export_tag = tag + "_" + datetime.now().strftime("%Y-%b-%d")
|
export_tag = tag + "_" + datetime.now().strftime("%Y-%b-%d")
|
||||||
else:
|
else:
|
||||||
@ -72,7 +76,12 @@ def export_db(tag=None, template=None):
|
|||||||
recipe_folder.mkdir(parents=True, exist_ok=True)
|
recipe_folder.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
export_images(img_folder)
|
export_images(img_folder)
|
||||||
export_recipes(recipe_folder, template)
|
|
||||||
|
if type(templates) == list:
|
||||||
|
for template in templates:
|
||||||
|
export_recipes(recipe_folder, template)
|
||||||
|
elif type(templates) == str:
|
||||||
|
export_recipes(recipe_folder, templates)
|
||||||
|
|
||||||
zip_path = BACKUP_DIR.joinpath(f"{export_tag}")
|
zip_path = BACKUP_DIR.joinpath(f"{export_tag}")
|
||||||
shutil.make_archive(zip_path, "zip", backup_folder)
|
shutil.make_archive(zip_path, "zip", backup_folder)
|
||||||
@ -93,7 +102,7 @@ def export_recipes(dest_dir: Path, template=None) -> Path:
|
|||||||
json_recipe = recipe.to_json(indent=4)
|
json_recipe = recipe.to_json(indent=4)
|
||||||
|
|
||||||
if template:
|
if template:
|
||||||
md_dest = dest_dir.parent.joinpath("markdown")
|
md_dest = dest_dir.parent.joinpath("templates")
|
||||||
md_dest.mkdir(parents=True, exist_ok=True)
|
md_dest.mkdir(parents=True, exist_ok=True)
|
||||||
template = TEMPLATE_DIR.joinpath(template)
|
template = TEMPLATE_DIR.joinpath(template)
|
||||||
export_markdown(md_dest, json_recipe, template)
|
export_markdown(md_dest, json_recipe, template)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user