mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
33 lines
883 B
Python
33 lines
883 B
Python
import sys
|
|
import shutil
|
|
import subprocess
|
|
|
|
|
|
def main ():
|
|
|
|
argument = str(sys.argv[1])
|
|
|
|
## Main Commands
|
|
if argument == 'backup_db':
|
|
res = backup_db()
|
|
print(res)
|
|
|
|
if argument == 'restore_db':
|
|
res = restore_db()
|
|
|
|
def backup_db ():
|
|
# Header
|
|
result = subprocess.run(["cp", "/home/pi/pialert/db/pialert.db", "/home/pi/pialert/config/pialert.db_bak"], stderr=subprocess.PIPE, text=True)
|
|
#shutil.copyfile("/home/pi/pialert/db/pialert.db", "/home/pi/pialert/config/pialert.db_bak")
|
|
|
|
|
|
def restore_db ():
|
|
# Header
|
|
shutil.copyfile("/home/pi/pialert/config/pialert.db_bak", "/home/pi/pialert/db/pialert.db")
|
|
|
|
|
|
#===============================================================================
|
|
# BEGIN
|
|
#===============================================================================
|
|
if __name__ == '__main__':
|
|
sys.exit(main()) |