This repository has been archived by the owner on Mar 23, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpykup.py
91 lines (76 loc) · 1.58 KB
/
pykup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env python
import argparse
from core import backup, cron
from sys import platform
if platform not in ['linux', 'linux2']:
print("Incorrect operative system")
exit(255)
parser = argparse.ArgumentParser(description='PyBack WebApp backup utils')
parser.add_argument(
'-d',
action='store',
dest='directory',
help="Set a backup directory",
type=str,
default=None,
required=True
)
parser.add_argument(
'-n',
action='store',
dest='app_name',
help="Define application name",
type=str,
default=None
)
parser.add_argument(
'-cF',
action='store',
dest='config_file',
help="Define configuration file",
type=str,
default=None,
required=True
)
parser.add_argument(
'-uD',
action='store',
dest='upload_driver',
help="Define upload driver dropbox|scp",
type=str,
default=None
)
parser.add_argument(
'-rF',
action='store',
dest='remote_folder',
help="Define scp remote folder",
type=str,
default=None
)
parser.add_argument(
'--cron',
action='store_true',
dest='cron',
help="Set command in crontab",
default=False
)
parser.add_argument(
'--telegram',
action='store_true',
dest='telegram',
help="Send telegram notification after backup",
default=False
)
args = parser.parse_args()
if args.cron is True:
cron_tab = cron.CronIntegration(args)
cron_tab.insert_new_job()
if args.directory is None:
print('You must insert a directory')
exit(255)
backup = backup.Backup(args.directory, args.app_name, args.config_file, args.telegram)
dump = backup.database()
file = backup.content()
backup.upload(args.upload_driver, args.remote_folder)
backup.delete_local_backup()