-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathbackup-ssh.py
35 lines (31 loc) · 1.09 KB
/
backup-ssh.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
import os
import sshx
from time import sleep
from pathlib import Path
folder = 'backup'
sleeper = 3600 * 6
if os.path.isdir(folder) is False:
os.makedirs(folder)
def main():
hosts, remarks = sshx.HOSTS()
for host in hosts:
port, username, password, panel, route_path, sshport, udgpw, remark = sshx.HOST_INFO(host)
try:
Session = sshx.PANNEL(host, username, password, port, panel, 'Other', 'uname')
status, content = Session.Backup_content()
if status is True:
if panel in ['dragon']:
f = folder + "/" + host + ".vps"
else:
f = folder + "/" + host + ".sql"
if Path(f).is_file() is True:
os.remove(f)
with open(f, 'wb') as file:
file.write(content)
else:
print("[-] Backup Error: " + content + " | " + host)
except Exception as e:
print("[-] Backup Error: " + str(e) + " | " + host)
while True:
main()
sleep(sleeper)