-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackup.py
executable file
·42 lines (32 loc) · 997 Bytes
/
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
#!/usr/bin/env python
import time
import threading
import os
import json
class backupThread(threading.Thread):
def __init__(self, backupMountScript, localImageFolder, backupDirectory):
threading.Thread.__init__(self)
self.localImageFolder = localImageFolder
self.backupDirectory = backupDirectory
print "mounting nas"
os.system(backupMountScript)
def start(self):
#time.sleep(30)
while True:
#print "backing up"
os.system("sudo rsync -a "+self.localImageFolder+" "+self.backupDirectory)
time.sleep(10)
settings = None
time.sleep(60)
with open('/media/usb/settings.json') as data_file:
settings = json.load(data_file)
print settings["backupActive"]
if settings["backupActive"]:
b = backupThread(
settings["backupMountScript"],
settings["localImageFolder"],
settings["backupDirectory"]
)
b.start()
else:
ainput = raw_input("Backup deactivated")