mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-09 03:04:54 -04:00
Fixed backup, updated backup docu (#430)
* Fixed backup, updated docu * reformatted
This commit is contained in:
parent
de80516722
commit
d126f74d35
@ -38,16 +38,24 @@ curl -X 'POST' \
|
|||||||
"settings": true,
|
"settings": true,
|
||||||
"themes": true
|
"themes": true
|
||||||
},
|
},
|
||||||
"template": [
|
"templates": [
|
||||||
"recipes.md"
|
"recipes.md"
|
||||||
]
|
]
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
### wget Example
|
### wget Example
|
||||||
Download a backup with `wget`
|
First request a file token with curl:
|
||||||
```bash
|
```bash
|
||||||
wget http://localhost:9000/api/backups/{file_name}/download
|
curl -X 'GET' \
|
||||||
|
'http://localhost:9000/api/backups/{file_name}/download' \
|
||||||
|
-H 'accept: application/json' \
|
||||||
|
-H 'Content-Type: application/json'
|
||||||
|
```
|
||||||
|
|
||||||
|
Then download the file with wget:
|
||||||
|
```bash
|
||||||
|
wget http://localhost:9000/api/utils/download?token={fileToken}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ from fastapi import HTTPException, status
|
|||||||
router = APIRouter(prefix="/api/utils", tags=["Utils"], include_in_schema=True)
|
router = APIRouter(prefix="/api/utils", tags=["Utils"], include_in_schema=True)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/download")
|
@router.get("/download/{token}")
|
||||||
async def download_file(file_path: Optional[Path] = Depends(validate_file_token)):
|
async def download_file(file_path: Optional[Path] = Depends(validate_file_token)):
|
||||||
"""Uses a file token obtained by an active user to retrieve a file from the operating
|
"""Uses a file token obtained by an active user to retrieve a file from the operating
|
||||||
system."""
|
system."""
|
||||||
|
@ -52,21 +52,22 @@ class ExportDatabase:
|
|||||||
dir.mkdir(parents=True, exist_ok=True)
|
dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
def export_templates(self, recipe_list: list[BaseModel]):
|
def export_templates(self, recipe_list: list[BaseModel]):
|
||||||
for template_path in self.templates:
|
if self.templates:
|
||||||
out_dir = self.templates_dir.joinpath(template_path.name)
|
for template_path in self.templates:
|
||||||
out_dir.mkdir(parents=True, exist_ok=True)
|
out_dir = self.templates_dir.joinpath(template_path.name)
|
||||||
|
out_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
with open(template_path, "r") as f:
|
with open(template_path, "r") as f:
|
||||||
template = Template(f.read())
|
template = Template(f.read())
|
||||||
|
|
||||||
for recipe in recipe_list:
|
for recipe in recipe_list:
|
||||||
filename = recipe.slug + template_path.suffix
|
filename = recipe.slug + template_path.suffix
|
||||||
out_file = out_dir.joinpath(filename)
|
out_file = out_dir.joinpath(filename)
|
||||||
|
|
||||||
content = template.render(recipe=recipe)
|
content = template.render(recipe=recipe)
|
||||||
|
|
||||||
with open(out_file, "w") as f:
|
with open(out_file, "w") as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
|
|
||||||
def export_recipe_dirs(self):
|
def export_recipe_dirs(self):
|
||||||
shutil.copytree(app_dirs.RECIPE_DATA_DIR, self.recipes, dirs_exist_ok=True)
|
shutil.copytree(app_dirs.RECIPE_DATA_DIR, self.recipes, dirs_exist_ok=True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user