mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
basic backup implementation (in progress)
This commit is contained in:
parent
9abb97627c
commit
ee4eca33d4
1
TODO
1
TODO
@ -12,6 +12,7 @@ New features:
|
|||||||
- javascript editor
|
- javascript editor
|
||||||
- persisted recent notes (is wiped out after reload)
|
- persisted recent notes (is wiped out after reload)
|
||||||
- sync of current page?
|
- sync of current page?
|
||||||
|
- create new subnote from inside the editor - possibly with selection of text
|
||||||
|
|
||||||
Refactorings:
|
Refactorings:
|
||||||
- modularize frontend
|
- modularize frontend
|
||||||
|
22
src/backup.py
Normal file
22
src/backup.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
import utils
|
||||||
|
from sql import getOption, setOption
|
||||||
|
import config_provider
|
||||||
|
from shutil import copyfile
|
||||||
|
|
||||||
|
def backup():
|
||||||
|
now = utils.nowTimestamp()
|
||||||
|
last_backup_date = int(getOption('last_backup_date'))
|
||||||
|
|
||||||
|
if now - last_backup_date > 43200:
|
||||||
|
config = config_provider.getConfig()
|
||||||
|
|
||||||
|
document_path = config['Document']['documentPath']
|
||||||
|
backup_directory = config['Backup']['backupDirectory']
|
||||||
|
|
||||||
|
date_str = datetime.utcnow().strftime("%Y-%m-%d %H:%M")
|
||||||
|
|
||||||
|
copyfile(document_path, backup_directory + "/" + "backup-" + date_str + ".db")
|
||||||
|
|
||||||
|
setOption('last_backup_date', now)
|
@ -1,19 +1,20 @@
|
|||||||
import base64
|
import base64
|
||||||
import os
|
import os
|
||||||
import math
|
|
||||||
import time
|
|
||||||
|
|
||||||
from flask import Blueprint, jsonify
|
from flask import Blueprint, jsonify
|
||||||
from flask_login import login_required
|
from flask_login import login_required
|
||||||
|
|
||||||
from sql import getResults, getSingleResult, getOption
|
from sql import getResults, getSingleResult, getOption
|
||||||
import utils
|
import utils
|
||||||
|
import backup
|
||||||
|
|
||||||
tree_api = Blueprint('tree_api', __name__)
|
tree_api = Blueprint('tree_api', __name__)
|
||||||
|
|
||||||
@tree_api.route('/api/tree', methods = ['GET'])
|
@tree_api.route('/api/tree', methods = ['GET'])
|
||||||
@login_required
|
@login_required
|
||||||
def getTree():
|
def getTree():
|
||||||
|
backup.backup()
|
||||||
|
|
||||||
notes = getResults("select "
|
notes = getResults("select "
|
||||||
"notes_tree.*, "
|
"notes_tree.*, "
|
||||||
"COALESCE(clone.note_title, notes.note_title) as note_title, "
|
"COALESCE(clone.note_title, notes.note_title) as note_title, "
|
||||||
|
@ -2,4 +2,4 @@ from datetime import datetime
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
def nowTimestamp():
|
def nowTimestamp():
|
||||||
return time.mktime(datetime.utcnow().timetuple())
|
return int(time.mktime(datetime.utcnow().timetuple()))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user