32 lines
857 B
Python
32 lines
857 B
Python
#!/usr/bin/env python3
|
|
"""Sauvegardes applicatives par groupe.
|
|
|
|
Usage:
|
|
cd /opt/app/backend
|
|
venv/bin/python ../deploy/group_backup.py all
|
|
"""
|
|
import asyncio
|
|
import os
|
|
import sys
|
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "backend"))
|
|
|
|
from app.core.database import async_session, engine # noqa: E402
|
|
from app.services.group_backups import creer_sauvegardes_tous_groupes # noqa: E402
|
|
|
|
|
|
async def main():
|
|
if len(sys.argv) < 2 or sys.argv[1] != "all":
|
|
print("Usage: group_backup.py all", file=sys.stderr)
|
|
return 2
|
|
async with async_session() as db:
|
|
backups = await creer_sauvegardes_tous_groupes(db)
|
|
await db.commit()
|
|
for backup in backups:
|
|
print(f"{backup['fichier']}")
|
|
await engine.dispose()
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(asyncio.run(main()))
|