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 %} + +
+
+ +
+
+
+ {% if backup_running %} +

+  {{ _('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.') }} +

+
+ {% if available_backups %} +
    + {% for backup in available_backups %} +
  • + {{ backup["filename"] }} {{ backup["filesize"] }} {{ _('Mb') }} +
  • + {% endfor %} +
+ {% else %} +

+ {{ _('No backups found.') }} +

+ {% endif %} + + {{ _('Create backup') }} + {% if available_backups %} + {{ _('Remove backups') }} + {% endif %} + +
+ +
+
+{% endblock %} diff --git a/changedetectionio/blueprint/backups/templates/backup_restore.html b/changedetectionio/blueprint/backups/templates/backup_restore.html new file mode 100644 index 000000000..6d5c4eabb --- /dev/null +++ b/changedetectionio/blueprint/backups/templates/backup_restore.html @@ -0,0 +1,52 @@ +{% extends 'base.html' %} +{% block content %} + {% from '_helpers.html' import render_field, render_checkbox_field %} + +
+
+ +
+
+
+

{{ _('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.') }}

+ +
+ + +
+ {{ render_checkbox_field(form.include_groups) }} + {{ _('Include all groups found in backup?') }} +
+
+ {{ render_checkbox_field(form.include_groups_replace_existing) }} + {{ _('Replace any existing groups of the same UUID?') }} +
+ +
+ {{ render_checkbox_field(form.include_watches) }} + {{ _('Include all watches found in backup?') }} +
+
+ {{ render_checkbox_field(form.include_watches_replace_existing) }} + {{ _('Replace any existing watches of the same UUID?') }} +
+ +
+ {{ render_field(form.zip_file) }} +
+ +
+ +
+
+
+
+
+{% endblock %} diff --git a/changedetectionio/blueprint/backups/templates/overview.html b/changedetectionio/blueprint/backups/templates/overview.html deleted file mode 100644 index 07b0af8af..000000000 --- a/changedetectionio/blueprint/backups/templates/overview.html +++ /dev/null @@ -1,36 +0,0 @@ -{% extends 'base.html' %} -{% block content %} - {% from '_helpers.html' import render_simple_field, render_field %} -
-
-

{{ _('Backups') }}

- {% if backup_running %} -

-  {{ _('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.') }} -

-
- {% if available_backups %} - - {% else %} -

- {{ _('No backups found.') }} -

- {% endif %} - - {{ _('Create backup') }} - {% if available_backups %} - {{ _('Remove backups') }} - {% endif %} -
-
- - -{% endblock %} diff --git a/changedetectionio/blueprint/imports/templates/import.html b/changedetectionio/blueprint/imports/templates/import.html index dc623b9e7..384bcc800 100644 --- a/changedetectionio/blueprint/imports/templates/import.html +++ b/changedetectionio/blueprint/imports/templates/import.html @@ -16,6 +16,11 @@
+ +

+ {{ _('Restoring changedetection.io backups is in the') }} {{ _('backups section') }}. +
+

{{ _('Enter one URL per line, and optionally add tags for each URL after a space, delineated by comma (,):') }}
@@ -37,9 +42,6 @@
- - -
{{ _('Copy and Paste your Distill.io watch \'export\' file, this should be a JSON file.') }}
{{ _('This is') }} {{ _('experimental') }}, {{ _('supported fields are') }} name, uri, tags, config:selections, {{ _('the rest (including') }} schedule) {{ _('are ignored.') }} @@ -49,8 +51,6 @@ {{ _('Be sure to set your default fetcher to Chrome if required.') }}

- -