| 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() |