mirror of
https://github.com/tubearchivist/tubearchivist
synced 2024-11-04 12:00:21 +00:00
added restore_from_backup to frontend and task
This commit is contained in:
parent
c17e2e6dd1
commit
1c3ca8364c
@ -10,7 +10,7 @@ from celery import Celery, shared_task
|
||||
from home.src.config import AppConfig
|
||||
from home.src.download import ChannelSubscription, PendingList, VideoDownloader
|
||||
from home.src.helper import get_lock
|
||||
from home.src.index_management import backup_all_indexes
|
||||
from home.src.index_management import backup_all_indexes, restore_from_backup
|
||||
from home.src.reindex import ManualImport, reindex_old_documents
|
||||
|
||||
CONFIG = AppConfig().config
|
||||
@ -94,3 +94,10 @@ def run_backup():
|
||||
""" called from settings page, dump backup to zip file """
|
||||
backup_all_indexes()
|
||||
print('backup finished')
|
||||
|
||||
|
||||
@shared_task
|
||||
def run_restore_backup():
|
||||
""" called from settings page, dump backup to zip file """
|
||||
restore_from_backup()
|
||||
print('index restore finished')
|
||||
|
@ -127,8 +127,12 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="settings-group">
|
||||
<p>Restore from backup.</p>
|
||||
<i>Coming soon</i>
|
||||
<h2>Restore from backup</h2>
|
||||
<p><span class="danger-zone">Danger Zone</span>: This will replace your existing index with the backup.</p>
|
||||
<p>Add the backup zip file to the <span class="settings-current">cache/backup</span> folder.</p>
|
||||
<div id="db-restore">
|
||||
<button onclick="dbRestore()">Restore backup</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="settings-group">
|
||||
<p>Rescan filesystem.</p>
|
||||
|
@ -20,7 +20,8 @@ from home.src.helper import (get_dl_message, get_message, process_url_list,
|
||||
set_message)
|
||||
from home.src.searching import Pagination, SearchHandler
|
||||
from home.tasks import (download_pending, download_single, extrac_dl,
|
||||
run_backup, run_manual_import, update_subscribed)
|
||||
run_backup, run_manual_import, run_restore_backup,
|
||||
update_subscribed)
|
||||
|
||||
|
||||
class HomeView(View):
|
||||
@ -461,7 +462,7 @@ class PostData:
|
||||
"watched", "rescan_pending", "ignore", "dl_pending",
|
||||
"unsubscribe", "sort_order", "hide_watched", "show_subed_only",
|
||||
"channel-search", "video-search", "dlnow", "manual-import",
|
||||
"db-backup"
|
||||
"db-backup", "db-restore"
|
||||
]
|
||||
|
||||
def __init__(self, post_dict):
|
||||
@ -536,6 +537,9 @@ class PostData:
|
||||
elif task == 'db-backup':
|
||||
print('backing up database')
|
||||
run_backup.delay()
|
||||
elif task == 'db-restore':
|
||||
print('restoring index from backup zip')
|
||||
run_restore_backup.delay()
|
||||
return {'success': True}
|
||||
|
||||
def search_channels(self, search_query):
|
||||
|
@ -493,6 +493,11 @@ button:hover {
|
||||
min-width: 300px;
|
||||
}
|
||||
|
||||
.danger-zone {
|
||||
background-color: var(--highlight-error);
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
/* about */
|
||||
.about-section {
|
||||
padding: 20px 0;
|
||||
|
@ -102,6 +102,17 @@ function dbBackup() {
|
||||
toReplace.appendChild(message);
|
||||
}
|
||||
|
||||
function dbRestore() {
|
||||
var payload = JSON.stringify({'db-restore': true});
|
||||
sendPost(payload)
|
||||
// clear button
|
||||
var message = document.createElement('p');
|
||||
message.innerText = 'restoring from backup';
|
||||
var toReplace = document.getElementById('db-restore');
|
||||
toReplace.innerHTML = '';
|
||||
toReplace.appendChild(message);
|
||||
}
|
||||
|
||||
// player
|
||||
function createPlayer(button) {
|
||||
var mediaUrl = button.getAttribute('data-src');
|
||||
|
Loading…
Reference in New Issue
Block a user