mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Added automatic backups
This commit is contained in:
parent
14fb4b4023
commit
b87379ed98
@ -7,7 +7,7 @@ author = {
|
||||
"email":"maloja@krateng.dev",
|
||||
"github": "krateng"
|
||||
}
|
||||
version = 2,0,14
|
||||
version = 2,1
|
||||
versionstr = ".".join(str(n) for n in version)
|
||||
|
||||
|
||||
|
@ -161,9 +161,9 @@ def loadlastfm(filename):
|
||||
def direct():
|
||||
from . import server
|
||||
|
||||
def backup(level="full"):
|
||||
def backup(level="full",folder=origpath):
|
||||
import tarfile
|
||||
from datetime import date
|
||||
from datetime import datetime
|
||||
import glob
|
||||
|
||||
|
||||
@ -186,10 +186,10 @@ def backup(level="full"):
|
||||
for g in user_files:
|
||||
real_files += glob.glob(g)
|
||||
|
||||
today = date.today()
|
||||
datestr = "-".join((str(today.year),str(today.month),str(today.day)))
|
||||
filename = "maloja_backup_" + datestr + ".tar.gz"
|
||||
archivefile = os.path.join(origpath,filename)
|
||||
now = datetime.utcnow()
|
||||
timestr = now.strftime("%Y_%m_%d_%H_%M_%S")
|
||||
filename = "maloja_backup_" + timestr + ".tar.gz"
|
||||
archivefile = os.path.join(folder,filename)
|
||||
assert not os.path.exists(archivefile)
|
||||
with tarfile.open(name=archivefile,mode="x:gz") as archive:
|
||||
for f in real_files:
|
||||
|
0
maloja/data_files/backups/dummy
Normal file
0
maloja/data_files/backups/dummy
Normal file
@ -7,6 +7,7 @@ from .cleanup import CleanerAgent
|
||||
from doreah.logging import log
|
||||
import difflib
|
||||
import datetime
|
||||
from .controller import backup
|
||||
|
||||
wendigo = CleanerAgent()
|
||||
|
||||
@ -17,6 +18,8 @@ pthj = os.path.join
|
||||
|
||||
def fix():
|
||||
|
||||
backup(level="minimal",folder=pthj(DATA_DIR,"backups"))
|
||||
|
||||
now = datetime.datetime.utcnow()
|
||||
nowstr = now.strftime("%Y_%m_%d_%H_%M_%S")
|
||||
datestr = now.strftime("%Y/%m/%d")
|
||||
|
Loading…
Reference in New Issue
Block a user