implement backup, fix ret date bug
This commit is contained in:
25
src/logic/backup.py
Normal file
25
src/logic/backup.py
Normal 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
|
||||
Reference in New Issue
Block a user