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",
|
"email":"maloja@krateng.dev",
|
||||||
"github": "krateng"
|
"github": "krateng"
|
||||||
}
|
}
|
||||||
version = 2,0,14
|
version = 2,1
|
||||||
versionstr = ".".join(str(n) for n in version)
|
versionstr = ".".join(str(n) for n in version)
|
||||||
|
|
||||||
|
|
||||||
|
@ -161,9 +161,9 @@ def loadlastfm(filename):
|
|||||||
def direct():
|
def direct():
|
||||||
from . import server
|
from . import server
|
||||||
|
|
||||||
def backup(level="full"):
|
def backup(level="full",folder=origpath):
|
||||||
import tarfile
|
import tarfile
|
||||||
from datetime import date
|
from datetime import datetime
|
||||||
import glob
|
import glob
|
||||||
|
|
||||||
|
|
||||||
@ -186,10 +186,10 @@ def backup(level="full"):
|
|||||||
for g in user_files:
|
for g in user_files:
|
||||||
real_files += glob.glob(g)
|
real_files += glob.glob(g)
|
||||||
|
|
||||||
today = date.today()
|
now = datetime.utcnow()
|
||||||
datestr = "-".join((str(today.year),str(today.month),str(today.day)))
|
timestr = now.strftime("%Y_%m_%d_%H_%M_%S")
|
||||||
filename = "maloja_backup_" + datestr + ".tar.gz"
|
filename = "maloja_backup_" + timestr + ".tar.gz"
|
||||||
archivefile = os.path.join(origpath,filename)
|
archivefile = os.path.join(folder,filename)
|
||||||
assert not os.path.exists(archivefile)
|
assert not os.path.exists(archivefile)
|
||||||
with tarfile.open(name=archivefile,mode="x:gz") as archive:
|
with tarfile.open(name=archivefile,mode="x:gz") as archive:
|
||||||
for f in real_files:
|
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
|
from doreah.logging import log
|
||||||
import difflib
|
import difflib
|
||||||
import datetime
|
import datetime
|
||||||
|
from .controller import backup
|
||||||
|
|
||||||
wendigo = CleanerAgent()
|
wendigo = CleanerAgent()
|
||||||
|
|
||||||
@ -17,6 +18,8 @@ pthj = os.path.join
|
|||||||
|
|
||||||
def fix():
|
def fix():
|
||||||
|
|
||||||
|
backup(level="minimal",folder=pthj(DATA_DIR,"backups"))
|
||||||
|
|
||||||
now = datetime.datetime.utcnow()
|
now = datetime.datetime.utcnow()
|
||||||
nowstr = now.strftime("%Y_%m_%d_%H_%M_%S")
|
nowstr = now.strftime("%Y_%m_%d_%H_%M_%S")
|
||||||
datestr = now.strftime("%Y/%m/%d")
|
datestr = now.strftime("%Y/%m/%d")
|
||||||
|
Loading…
Reference in New Issue
Block a user