-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwarshade.py
More file actions
82 lines (67 loc) · 3.6 KB
/
warshade.py
File metadata and controls
82 lines (67 loc) · 3.6 KB
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
import functions, argparse
from subprocess import run
from sys import exit
# Here we add CLI arguments for quick-and-easy execution instead of having to go through the menu.
parser = argparse.ArgumentParser()
parser.add_argument("-fb", "--fullBackup", action = "store_true", help = "Backs up the server.\n")
parser.add_argument("-dbb", "--dbBackup", action = "store_true", help = "Backs up the database and timestamps it.\n")
parser.add_argument("-wb", "--webBackup", action = "store_true", help = "Backs up NGINX, Certs, and other important files such as the website NGINX is running.\n")
parser.add_argument("-tb", "--Transfer", action = "store_true", help = "Transfers to a new server.\n")
parser.add_argument("-s", "--Setup", action = "store_true", help = "Installs necessary files for the server. To see what's installed, view 'programs.py'.\n")
parser.add_argument("-fr", "--fullRestore", action = "store_true", help = "This restores the server, putting the files we've backed up, back into their proper directories.\n")
parser.add_argument("-dbr", "--dbRestore", action = "store_true", help = "This allows the user to select a specific .sql database and restore it.\n")
parser.add_argument("-wbr", "--webRestore", action = "store_true", help = "This attempts to restore the NGINX and webBackup that a user selects in the /tmp/ directory.\n")
args = parser.parse_args()
# Here we're checking to see if any CLI arguments were passed before execution. If none were passed, then we follow through with the default state.
try:
if args.fullBackup:
functions.fullBackup()
elif args.dbBackup:
functions.dbBackup()
elif args.webBackup:
functions.webBackup()
elif args.Transfer:
functions.transferBackup()
elif args.Setup:
functions.serverSetup()
elif args.fullRestore:
functions.fullRestore()
elif args.dbRestore:
functions.dbRestore()
elif args.webRestore:
functions.webRestore()
while True:
run(['clear'], shell=True)
print('\t Welcome to Warshade! What would you like to do? \n')
print('\t 1: Full Backup')
print('\t 2: Database Backup')
print('\t 3: Website / NGINX Backup\n')
print('\t 4: Transfer Backup')
print('\t 5: Server Setup\n')
print('\t 6: Restore Full Backup')
print('\t 7: Restore Database')
print('\t 8: Restore Website\n')
print('\t 9: Exit \n')
response = input('\t Please input your selection as a number: ')
run(['clear'], shell=True)
if response == '1':
functions.fullBackup()
elif response == '2':
functions.dbBackup()
elif response == '3':
functions.webBackup()
elif response == '4':
functions.transferBackup()
elif response == '5':
functions.serverSetup()
elif response == '6':
functions.fullRestore()
elif response == '7':
functions.dbRestore()
elif response == '8':
functions.webRestore()
elif response == '9':
exit()
except KeyboardInterrupt:
run(['clear'], shell=True)
print('\t User has purposefully interrupted the execution of the program.\n')