diff --git a/changedetectionio/blueprint/backups/__init__.py b/changedetectionio/blueprint/backups/__init__.py index 2257b1543..6959c8c18 100644 --- a/changedetectionio/blueprint/backups/__init__.py +++ b/changedetectionio/blueprint/backups/__init__.py @@ -88,7 +88,10 @@ def create_backup(datastore_path, watches: dict): def construct_blueprint(datastore: ChangeDetectionStore): + from .restore import construct_restore_blueprint + backups_blueprint = Blueprint('backups', __name__, template_folder="templates") + backups_blueprint.register_blueprint(construct_restore_blueprint(datastore)) backup_threads = [] @login_optionally_required @@ -96,11 +99,11 @@ def construct_blueprint(datastore: ChangeDetectionStore): def request_backup(): if any(thread.is_alive() for thread in backup_threads): flash(gettext("A backup is already running, check back in a few minutes"), "error") - return redirect(url_for('backups.index')) + return redirect(url_for('backups.create')) if len(find_backups()) > int(os.getenv("MAX_NUMBER_BACKUPS", 100)): flash(gettext("Maximum number of backups reached, please remove some"), "error") - return redirect(url_for('backups.index')) + return redirect(url_for('backups.create')) # With immediate persistence, all data is already saved zip_thread = threading.Thread( @@ -113,7 +116,7 @@ def construct_blueprint(datastore: ChangeDetectionStore): backup_threads.append(zip_thread) flash(gettext("Backup building in background, check back in a few minutes.")) - return redirect(url_for('backups.index')) + return redirect(url_for('backups.create')) def find_backups(): backup_filepath = os.path.join(datastore.datastore_path, BACKUP_FILENAME_FORMAT.format("*")) @@ -155,14 +158,14 @@ def construct_blueprint(datastore: ChangeDetectionStore): return send_from_directory(os.path.abspath(datastore.datastore_path), filename, as_attachment=True) @login_optionally_required - @backups_blueprint.route("", methods=['GET']) - def index(): + @backups_blueprint.route("/", methods=['GET']) + @backups_blueprint.route("/create", methods=['GET']) + def create(): backups = find_backups() - output = render_template("overview.html", + output = render_template("backup_create.html", available_backups=backups, backup_running=any(thread.is_alive() for thread in backup_threads) ) - return output @login_optionally_required @@ -176,6 +179,6 @@ def construct_blueprint(datastore: ChangeDetectionStore): flash(gettext("Backups were deleted.")) - return redirect(url_for('backups.index')) + return redirect(url_for('backups.create')) return backups_blueprint diff --git a/changedetectionio/blueprint/backups/templates/backup_create.html b/changedetectionio/blueprint/backups/templates/backup_create.html new file mode 100644 index 000000000..21678fd27 --- /dev/null +++ b/changedetectionio/blueprint/backups/templates/backup_create.html @@ -0,0 +1,49 @@ +{% extends 'base.html' %} +{% block content %} + {% from '_helpers.html' import render_simple_field, render_field %} + +
+ {{ _('A backup is running!') }} +
+ {% endif %} + ++ {{ _('Here you can download and request a new backup, when a backup is completed you will see it listed below.') }} +
++ {{ _('No backups found.') }} +
+ {% endif %} + + {{ _('Create backup') }} + {% if available_backups %} + {{ _('Remove backups') }} + {% endif %} + +{{ _('Restore a backup. Must be a .zip backup file created on/after v0.53.1 (new database layout).') }}
+{{ _('Note: This does not override the main application settings, only watches and groups.') }}
+ + +- {{ _('A backup is running!') }} -
- {% endif %} -- {{ _('Here you can download and request a new backup, when a backup is completed you will see it listed below.') }} -
-- {{ _('No backups found.') }} -
- {% endif %} - - {{ _('Create backup') }} - {% if available_backups %} - {{ _('Remove backups') }} - {% endif %} -