implement backup, fix ret date bug

This commit is contained in:
WorldTeacher
2024-07-17 09:02:27 +02:00
parent 923bfa8533
commit 8ab57d6913
2 changed files with 74 additions and 35 deletions

25
src/logic/backup.py Normal file
View File

@@ -0,0 +1,25 @@
import os
import sys
import shutil
from src import config
class Backup:
def __init__(self):
self.source_path = config.database.path + "/" + config.database.name
self.backup_path = config.database.backupLocation + "/" + config.database.name
self.backup = False
self.checkpaths()
def checkpaths(self):
if os.path.exists(config.database.backupLocation):
self.backup = True
def createBackup(self):
if self.backup:
if os.path.exists(self.source_path):
if os.path.exists(self.backup_path):
os.remove(self.backup_path)
shutil.copy(self.source_path, self.backup_path)
return True
return False