diff --git a/docs/bundledplugins/backup.rst b/docs/bundledplugins/backup.rst new file mode 100644 index 000000000..350d40508 --- /dev/null +++ b/docs/bundledplugins/backup.rst @@ -0,0 +1,70 @@ +.. _sec-bundledplugins-backup: + +Backup Plugin +============= + +The OctoPrint Backup Plugin comes bundled with OctoPrint (starting with 1.3.10). + +It allows the creation and restoration of backups of OctoPrint's settings, data and installed plugins [#]_. + +This allows easy migration +to newly setup instances as well as making regular backups to prevent data loss. + +.. _fig-bundledplugins-backup-settings: +.. figure:: ../images/bundledplugins-backup-settings.png + :align: center + :alt: OctoPrint Backup Plugin + + The plugin's settings panel with existing backups, the backup creation and restore sections. + +As long as plugins adhere to the standard of storing their data and settings in OctoPrint's plugin data folders, their +data will be part of the backup. Note that the backups made by the Backup Plugin will *not* be part of any backups - +you'll need to persist the resulting zip files yourself! + +.. _sec-bundledplugins-backup-cli: + +Command line usage +------------------ + +The Backup Plugin implements a command line interface that allows creation and restoration of backups. +It adds two new commands, ``backup:backup`` and ``backup_restore``. + +.. code-block:: none + + $ octoprint plugins backup:backup --help + Initializing settings & plugin subsystem... + Usage: octoprint plugins backup:backup [OPTIONS] + + Creates a new backup. + + Options: + --exclude TEXT Identifiers of data folders to exclude, e.g. 'uploads' to + exclude uploads or 'timelapse' to exclude timelapses. + --help Show this message and exit. + + $ octoprint plugins backup:restore --help + Initializing settings & plugin subsystem... + Usage: octoprint plugins backup:restore [OPTIONS] PATH + + Restores an existing backup from the backup zip provided as argument. + + OctoPrint does not need to run for this to proceed. + + Options: + --help Show this message and exit. + +.. note:: + + The ``backup:backup`` command can be useful in combination with a cronjob to create backups in regular intervals. + +.. _sec-bundledplugins-backup-sourcecode: + +Source code +----------- + +The source of the Backup plugin is bundled with OctoPrint and can be found in +its source repository under ``src/octoprint/plugins/backup``. + +.. [#] Note that only those plugins that are available on `OctoPrint's official plugin repository `_ + can be automatically restored. If you have plugins installed that are not available on there you'll get their + names and - if available - homepage URL displayed after restore in order to be able to manually reinstall them. diff --git a/docs/bundledplugins/index.rst b/docs/bundledplugins/index.rst index 7dc337991..ec90f709c 100644 --- a/docs/bundledplugins/index.rst +++ b/docs/bundledplugins/index.rst @@ -9,6 +9,7 @@ Bundled Plugins action_command_prompt.rst announcements.rst + backup.rst cura.rst discovery.rst logging.rst diff --git a/docs/images/bundledplugins-backup-settings.png b/docs/images/bundledplugins-backup-settings.png new file mode 100644 index 000000000..1d21c69e8 Binary files /dev/null and b/docs/images/bundledplugins-backup-settings.png differ diff --git a/src/octoprint/plugins/backup/__init__.py b/src/octoprint/plugins/backup/__init__.py index 47ceb0a31..ad117cb0b 100644 --- a/src/octoprint/plugins/backup/__init__.py +++ b/src/octoprint/plugins/backup/__init__.py @@ -300,8 +300,14 @@ class BackupPlugin(octoprint.plugin.SettingsPlugin, import click @click.command("backup") - @click.option("--exclude", multiple=True) + @click.option("--exclude", multiple=True, + help="Identifiers of data folders to exclude, e.g. 'uploads' to exclude uploads or " + "'timelapse' to exclude timelapses.") def backup_command(exclude): + """ + Creates a new backup. + """ + backup_file = "backup-{}.zip".format(time.strftime("%Y%m%d-%H%M%S")) settings = octoprint.plugin.plugin_settings_for_settings_plugin("backup", self, settings=cli_group.settings) @@ -309,16 +315,22 @@ class BackupPlugin(octoprint.plugin.SettingsPlugin, if not os.path.isdir(datafolder): os.makedirs(datafolder) + click.echo("Creating backup at {}, please wait...".format(backup_file)) self._create_backup(backup_file, exclude=exclude, settings=settings, plugin_manager=cli_group.plugin_manager, datafolder=datafolder) - click.echo("Created {}".format(backup_file)) + click.echo("Done.") @click.command("restore") @click.argument("path") def restore_command(path): + """ + Restores an existing backup from the backup zip provided as argument. + + OctoPrint does not need to run for this to proceed. + """ settings = octoprint.plugin.plugin_settings_for_settings_plugin("backup", self, settings=cli_group.settings) plugin_manager = cli_group.plugin_manager