31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
from pathlib import Path
|
|
import shutil,subprocess
|
|
repo=Path(__file__).resolve().parents[2]
|
|
lab=Path.home()/'azerothai-pc-lab'
|
|
shutil.copy2(repo/'ale/azerothai_recovery.lua',lab/'azerothcore/azerothai-lua/azerothai_recovery.lua')
|
|
units=Path.home()/'.config/systemd/user';units.mkdir(parents=True,exist_ok=True)
|
|
python=shutil.which('python3');assert python
|
|
(units/'azerothai-backup.service').write_text(f'''[Unit]
|
|
Description=AzerothAI backup and isolated restore verification
|
|
[Service]
|
|
Type=oneshot
|
|
WorkingDirectory={repo}
|
|
ExecStart=/usr/bin/sg docker -c "{python} {repo}/scripts/realm-backup.py"
|
|
TimeoutStartSec=30min
|
|
Nice=10
|
|
UMask=0077
|
|
''')
|
|
(units/'azerothai-backup.timer').write_text('''[Unit]
|
|
Description=AzerothAI daily verified backup
|
|
[Timer]
|
|
OnCalendar=*-*-* 06:00:00 UTC
|
|
Persistent=true
|
|
RandomizedDelaySec=300
|
|
[Install]
|
|
WantedBy=timers.target
|
|
''')
|
|
subprocess.run(['systemctl','--user','daemon-reload'],check=True)
|
|
subprocess.run(['systemctl','--user','enable','--now','azerothai-backup.timer'],check=True)
|
|
print('Daily backup scheduled for 06:00 UTC; reload ALE to enable native recovery.')
|