-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremote-backup.py
executable file
·47 lines (39 loc) · 1.32 KB
/
remote-backup.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
#!/usr/bin/env python
import sys
from backup import *
from backup import jobs
import backup
def define_path():
global path_temp,settings
path_temp = settings['temp'].strip()
if path_temp == "":
print ("Temp directory blank. Please define a temporary directory on settings.json")
log("FAULT","admin","Temp directory blank. Script can't run without a temp directory.")
if path_temp[-1] != '/':
path_temp = path_temp+'2/'
backup.path_temp = path_temp
def run_jobs():
global destinations,path_temp
# cleanup
if clean_up()== 0:
log("INFO","admin","Cleaning up temp directory.")
for job in jobs:
job_name = job['name']
log("INFO", job_name,"REMOTE - Starting backup.")
#compress paths
if "path" in job:
compress_paths(job)
# Process docker
if "docker" in job:
compress_docker(job)
if __name__ == "__main__":
pathname = os.path.dirname(os.path.realpath(__file__))
os.chdir(pathname)
settings = read_settings()
define_path()
jobs = read_jobs()
read_destinations()
if sys.argv[1] == 'backup':
run_jobs()
if sys.argv[1] == 'cleanup':
clean_up()