File size: 586 Bytes
632b0a7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os, time, subprocess

def env_int(name, default):
    try:
        return int(os.getenv(name, str(default)))
    except Exception:
        return default

def main():
    if os.getenv("BACKUP_ENABLE", "0") != "1":
        print("BACKUP_ENABLE!=1,备份守护不运行")
        return

    every = env_int("BACKUP_EVERY_SECONDS", 3600)
    warmup = env_int("BACKUP_WARMUP_SECONDS", 60)
    time.sleep(warmup)

    while True:
        subprocess.run(["python3", "/home/user/backup_once.py"], check=False)
        time.sleep(max(60, every))

if __name__ == "__main__":
    main()