34 lines
974 B
Python
34 lines
974 B
Python
from config import cfg
|
|
import logging as log
|
|
from backup import read_device_list, save_mikrotik_bcp
|
|
from repo import check_bcp_repo, push_to_remote
|
|
import schedule
|
|
import time
|
|
|
|
|
|
def main():
|
|
check_bcp_repo()
|
|
device_dict = read_device_list()
|
|
for device in device_dict:
|
|
current_device = device_dict[device]
|
|
if current_device["vendor"].lower() == "mikrotik":
|
|
save_mikrotik_bcp(host=current_device["ip"], name=current_device["name"])
|
|
elif current_device["vendor"].lower() == "snr":
|
|
save_mikrotik_bcp(host=current_device["ip"], name=current_device["name"])
|
|
if cfg.git.push:
|
|
push_to_remote()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
log.info("Starting app")
|
|
schedule.every().day.at(cfg.bcp.start_at).do(main)
|
|
|
|
try:
|
|
main()
|
|
while True:
|
|
schedule.run_pending()
|
|
time.sleep(60)
|
|
except KeyboardInterrupt:
|
|
log.info("Manual app stopped")
|
|
log.info("App stopped")
|