From: Edward Delaporte Date: Sun, 7 Dec 2025 23:28:12 +0000 (-0600) Subject: Verify Luanti backup X-Git-Url: https://us-delaporte.pagekite.me/gitweb/dotfiles.git/commitdiff_plain/72c4e8b45b3bbe07bf0acda5b48d63ce3f68df5c?ds=sidebyside Verify Luanti backup --- diff --git a/invoke/luanti-remote/tasks.py b/invoke/luanti-remote/tasks.py index d0d5152..e6f5915 100644 --- a/invoke/luanti-remote/tasks.py +++ b/invoke/luanti-remote/tasks.py @@ -20,10 +20,6 @@ LOCAL_BACKUPS=f'{LOCAL_HOME}/backup/luanti' def browse(c, url): c.run(f"librefox {url}") -@task -def serve(c): - print(f"Attempting to connect to {IP}") - c.run(f'ssh {USER}@{IP} -C {SERVE}') @task def compress(c): @@ -31,6 +27,10 @@ def compress(c): @task(compress) def backup(c): + stopped = input("Is the server stopped?") + if(stopped != 'y'): + print("so go stop the server...") + exit() print(f'Backup {HOME}/{BACKUP_FILE} to {LOCAL_BACKUPS}') c.run(f'mkdir -p {LOCAL_BACKUPS}') c.run(f'{SCP}:{BACKUP_FILE} {LOCAL_BACKUPS}') @@ -53,10 +53,16 @@ def verify_backup(c): DB_FILE='map.sqlite' print(f'Extracting {DB_FILE} from {TAR_FILE}') c.run(f'tar --extract --file={LOCAL_BACKUPS}/{BACKUP_FILE} {WORLD}/{DB_FILE}') - result = c.run(f'echo "PRAGMA quick_check;" | sqlite3 {DB_FILE})') - print(f'Check on {DB_FILE}: {result}') - if(result != 'ok'): - print("database is corrupt, restore from backup") + result = c.run(f'echo "PRAGMA quick_check;" | sqlite3 {DB_FILE}') + # print(f'Check on {DB_FILE}: {result}') + # print(f'Exit code: {result.exited}') - + if(not 'ok' in result.stdout): + print("=========================================") + print("database is corrupt, restore from backup!") + print("=========================================") +@task(verify_backup) +def serve(c): + print(f"Attempting to connect to {IP}") + c.run(f'ssh {USER}@{IP} -C {SERVE}')