2
0
mirror of https://github.com/frappe/frappe_docker.git synced 2024-11-10 07:11:00 +00:00
frappe_docker/build/common/commands/backup.py
Chinmay D. Pai 884a82d814
fix: make semantic changes to commands
* add missing __main__ call to commands.py
* remove unnecessary imports
* fix backup WITH_FILES logic
* follow python semantics (?)

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>
2020-04-29 01:45:59 +05:30

36 lines
1009 B
Python

import os
import frappe
from frappe.utils.backups import scheduled_backup
from frappe.utils import cint, get_sites, now
def backup(sites, with_files=False):
for site in sites:
frappe.init(site)
frappe.connect()
odb = scheduled_backup(
ignore_files=not with_files,
backup_path_db=None,
backup_path_files=None,
backup_path_private_files=None,
force=True
)
print("database backup taken -", odb.backup_path_db, "- on", now())
if with_files:
print("files backup taken -", odb.backup_path_files, "- on", now())
print("private files backup taken -", odb.backup_path_private_files, "- on", now())
frappe.destroy()
def main():
installed_sites = ":".join(get_sites())
sites = os.environ.get("SITES", installed_sites).split(":")
with_files = cint(os.environ.get("WITH_FILES"))
backup(sites, with_files)
exit(0)
if __name__ == "__main__":
main()