tools/backup_prepare.py

20 lines
489 B
Python
Raw Permalink Normal View History

2021-11-30 14:51:26 +01:00
#!/usr/bin/env python3
import time
import sys
from mcrcon import MCRcon
from CONFIG import HOST,PW,PORT
flushed=False
with MCRcon(HOST, PW, port=PORT) as mcr:
resp = mcr.command("say BACKUP STARTED")
resp = mcr.command("save-off")
resp = mcr.command("save-all flush")
if "Saved the game" in resp:
flushed=True
print("Flushed map successfully. Don't forget to run enable_autosave.py after the map backup")
if flushed:
sys.exit(0)
else:
sys.exit(1)