From f6908c70187895c03cb9ef3bfd77f12cfa2006c1 Mon Sep 17 00:00:00 2001 From: Aitor Bouzas Date: Mon, 8 Oct 2018 15:04:31 +0200 Subject: [PATCH] [MIG] auto_backup: Migration to 12.0 Added test coverage Added requirements.txt for pysftp Added in the roadmap the exact version of pysftp for this to work (0.2.8) Added in the roadmap the problem with list_db=False Adapted calls to message_post --- auto_backup/README.rst | 84 +++- auto_backup/__manifest__.py | 16 +- auto_backup/models/db_backup.py | 12 +- auto_backup/readme/CONFIGURE.rst | 3 + auto_backup/readme/CONTRIBUTORS.rst | 6 + auto_backup/readme/DESCRIPTION.rst | 1 + auto_backup/readme/INSTALL.rst | 4 + auto_backup/readme/ROADMAP.rst | 6 + auto_backup/readme/USAGE.rst | 46 ++ auto_backup/static/description/index.html | 512 ++++++++++++++++++++++ auto_backup/tests/test_db_backup.py | 6 +- auto_backup/view/db_backup_view.xml | 2 +- requirements.txt | 1 + 13 files changed, 659 insertions(+), 40 deletions(-) create mode 100644 auto_backup/readme/CONFIGURE.rst create mode 100644 auto_backup/readme/CONTRIBUTORS.rst create mode 100644 auto_backup/readme/DESCRIPTION.rst create mode 100644 auto_backup/readme/INSTALL.rst create mode 100644 auto_backup/readme/ROADMAP.rst create mode 100644 auto_backup/readme/USAGE.rst create mode 100644 auto_backup/static/description/index.html diff --git a/auto_backup/README.rst b/auto_backup/README.rst index 1fb8820bd..2850e7767 100644 --- a/auto_backup/README.rst +++ b/auto_backup/README.rst @@ -1,19 +1,44 @@ -.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png - :target: https://www.gnu.org/licenses/agpl - :alt: License: AGPL-3 - ==================== Database Auto-Backup ==================== +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github + :target: https://github.com/OCA/server-tools/tree/12.0/auto_backup + :alt: OCA/server-tools +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-auto_backup + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/149/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + A tool for all your back-ups, internal and external! +**Table of contents** + +.. contents:: + :local: + Installation ============ Before installing this module, you need to execute:: - pip3 install pysftp + pip3 install pysftp==0.2.8 + Configuration ============= @@ -31,10 +56,10 @@ through an encrypted tunnel. You can even specify how long local backups and external backups should be kept, automatically! Connect with an FTP Server --------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~ Keep your data safe, through an SSH tunnel! -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +------------------------------------------- Want to go even further and write your backups to an external server? You can with this module! Specify the credentials to the server, specify @@ -43,10 +68,10 @@ through an SSH (encrypted) tunnel, thanks to pysftp, so your data is safe! Test connection ---------------- +~~~~~~~~~~~~~~~ Checks your credentials in one click -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +------------------------------------ Want to make sure if the connection details are correct and if Odoo can automatically write them to the remote server? Simply click on the ‘Test @@ -54,16 +79,16 @@ SFTP Connection’ button and you will get message telling you if everything is OK, or what is wrong! E-mail on backup failure ------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~ Stay informed of problems, automatically! -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +----------------------------------------- Do you want to know if the database backup succeeded or failed? Subscribe to the corresponding backup setting notification type. Run backups when you want -------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~ From the backups configuration list, press *More > Execute backup(s)* to manually execute the selected processes. @@ -80,38 +105,53 @@ Known issues / Roadmap you need to run the backup from outside of the main Odoo instance. How to do this is outlined in `this blog post `_. +* Backups won't work if list_db=False is configured in the instance. Bug Tracker =========== -Bugs are tracked on `GitHub Issues -`_. In case of trouble, please -check there if your issue has already been reported. If you spotted it first, -help us smash it by providing detailed and welcomed feedback. +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. Credits ======= +Authors +~~~~~~~ + +* Yenthe Van Ginneken +* Agile Business Group +* Grupo ESOC Ingenieria de Servicios +* LasLabs +* AdaptiveCity + Contributors ------------- +~~~~~~~~~~~~ * Yenthe Van Ginneken * Alessio Gerace * Jairo Llopis * Dave Lasley * Andrea Stirpe +* Aitor Bouzas + +Maintainers +~~~~~~~~~~~ -Maintainer ----------- +This module is maintained by the OCA. .. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association :target: https://odoo-community.org -This module is maintained by the OCA. - OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -To contribute to this module, please visit https://odoo-community.org. +This module is part of the `OCA/server-tools `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/auto_backup/__manifest__.py b/auto_backup/__manifest__.py index 8d1da2dcd..b2a5b661d 100644 --- a/auto_backup/__manifest__.py +++ b/auto_backup/__manifest__.py @@ -1,19 +1,19 @@ -# © 2004-2009 Tiny SPRL (). -# © 2015 Agile Business Group -# © 2016 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis +# Copyright 2004-2009 Tiny SPRL (). +# Copyright 2015 Agile Business Group +# Copyright 2016 Grupo ESOC Ingenieria de Servicios, S.L.U. - Jairo Llopis # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "Database Auto-Backup", "summary": "Backups database", - "version": "11.0.1.0.0", - "author": ( + "version": "12.0.1.0.0", + "author": "Yenthe Van Ginneken, " "Agile Business Group, " - "Grupo ESOC Ingeniería de Servicios, " + "Grupo ESOC Ingenieria de Servicios, " "LasLabs, " - "Odoo Community Association (OCA)" - ), + "AdaptiveCity, " + "Odoo Community Association (OCA)", "license": "AGPL-3", "website": "https://github.com/OCA/server-tools/", "category": "Tools", diff --git a/auto_backup/models/db_backup.py b/auto_backup/models/db_backup.py index 4c89787ee..be927eb7a 100644 --- a/auto_backup/models/db_backup.py +++ b/auto_backup/models/db_backup.py @@ -1,6 +1,6 @@ -# © 2004-2009 Tiny SPRL (). -# © 2015 Agile Business Group -# © 2016 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis +# Copyright 2004-2009 Tiny SPRL (). +# Copyright 2015 Agile Business Group +# Copyright 2016 Grupo ESOC Ingenieria de Servicios, S.L.U. - Jairo Llopis # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). import logging @@ -215,7 +215,7 @@ class DbBackup(models.Model): _logger.exception("Database backup failed: %s", self.name) escaped_tb = tools.html_escape(traceback.format_exc()) self.message_post( # pylint: disable=translation-required - "

%s

%s
" % ( + body="

%s

%s
" % ( _("Database backup failed."), escaped_tb), subtype=self.env.ref( @@ -224,7 +224,7 @@ class DbBackup(models.Model): ) else: _logger.info("Database backup succeeded: %s", self.name) - self.message_post(_("Database backup succeeded.")) + self.message_post(body=_("Database backup succeeded.")) @api.multi def cleanup(self): @@ -261,7 +261,7 @@ class DbBackup(models.Model): _logger.exception("Cleanup of old database backups failed: %s") escaped_tb = tools.html_escape(traceback.format_exc()) self.message_post( # pylint: disable=translation-required - "

%s

%s
" % ( + body="

%s

%s
" % ( _("Cleanup of old database backups failed."), escaped_tb), subtype=self.env.ref("auto_backup.failure")) diff --git a/auto_backup/readme/CONFIGURE.rst b/auto_backup/readme/CONFIGURE.rst new file mode 100644 index 000000000..406e81487 --- /dev/null +++ b/auto_backup/readme/CONFIGURE.rst @@ -0,0 +1,3 @@ +Go to *Settings -> Database Structure -> Automated Backup* to +create your configurations for each database that you needed +to backups. diff --git a/auto_backup/readme/CONTRIBUTORS.rst b/auto_backup/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..7ee6bb99e --- /dev/null +++ b/auto_backup/readme/CONTRIBUTORS.rst @@ -0,0 +1,6 @@ +* Yenthe Van Ginneken +* Alessio Gerace +* Jairo Llopis +* Dave Lasley +* Andrea Stirpe +* Aitor Bouzas diff --git a/auto_backup/readme/DESCRIPTION.rst b/auto_backup/readme/DESCRIPTION.rst new file mode 100644 index 000000000..c7add4633 --- /dev/null +++ b/auto_backup/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +A tool for all your back-ups, internal and external! diff --git a/auto_backup/readme/INSTALL.rst b/auto_backup/readme/INSTALL.rst new file mode 100644 index 000000000..595ea5a6d --- /dev/null +++ b/auto_backup/readme/INSTALL.rst @@ -0,0 +1,4 @@ +Before installing this module, you need to execute:: + + pip3 install pysftp==0.2.8 + diff --git a/auto_backup/readme/ROADMAP.rst b/auto_backup/readme/ROADMAP.rst new file mode 100644 index 000000000..e96ef407e --- /dev/null +++ b/auto_backup/readme/ROADMAP.rst @@ -0,0 +1,6 @@ +* On larger databases, it is possible that backups will die due to Odoo server + settings. In order to circumvent this without frivolously changing settings, + you need to run the backup from outside of the main Odoo instance. How to do + this is outlined in `this blog post + `_. +* Backups won't work if list_db=False is configured in the instance. diff --git a/auto_backup/readme/USAGE.rst b/auto_backup/readme/USAGE.rst new file mode 100644 index 000000000..bc3607e22 --- /dev/null +++ b/auto_backup/readme/USAGE.rst @@ -0,0 +1,46 @@ +Keep your Odoo data safe with this module. Take automated back-ups, +remove them automatically and even write them to an external server +through an encrypted tunnel. You can even specify how long local backups +and external backups should be kept, automatically! + +Connect with an FTP Server +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Keep your data safe, through an SSH tunnel! +------------------------------------------- + +Want to go even further and write your backups to an external server? +You can with this module! Specify the credentials to the server, specify +a path and everything will be backed up automatically. This is done +through an SSH (encrypted) tunnel, thanks to pysftp, so your data is +safe! + +Test connection +~~~~~~~~~~~~~~~ + +Checks your credentials in one click +------------------------------------ + +Want to make sure if the connection details are correct and if Odoo can +automatically write them to the remote server? Simply click on the ‘Test +SFTP Connection’ button and you will get message telling you if +everything is OK, or what is wrong! + +E-mail on backup failure +~~~~~~~~~~~~~~~~~~~~~~~~ + +Stay informed of problems, automatically! +----------------------------------------- + +Do you want to know if the database backup succeeded or failed? Subscribe to +the corresponding backup setting notification type. + +Run backups when you want +~~~~~~~~~~~~~~~~~~~~~~~~~ + +From the backups configuration list, press *More > Execute backup(s)* to +manually execute the selected processes. + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/149/11.0 diff --git a/auto_backup/static/description/index.html b/auto_backup/static/description/index.html new file mode 100644 index 000000000..2d8746cc4 --- /dev/null +++ b/auto_backup/static/description/index.html @@ -0,0 +1,512 @@ + + + + + + +Database Auto-Backup + + + +
+

Database Auto-Backup

+ + +

Beta License: AGPL-3 OCA/server-tools Translate me on Weblate Try me on Runbot

+

A tool for all your back-ups, internal and external!

+

Table of contents

+ +
+

Installation

+

Before installing this module, you need to execute:

+
+pip3 install pysftp==0.2.8
+
+
+
+

Configuration

+

Go to Settings -> Database Structure -> Automated Backup to +create your configurations for each database that you needed +to backups.

+
+
+

Usage

+

Keep your Odoo data safe with this module. Take automated back-ups, +remove them automatically and even write them to an external server +through an encrypted tunnel. You can even specify how long local backups +and external backups should be kept, automatically!

+
+

Connect with an FTP Server

+
+

Keep your data safe, through an SSH tunnel!

+

Want to go even further and write your backups to an external server? +You can with this module! Specify the credentials to the server, specify +a path and everything will be backed up automatically. This is done +through an SSH (encrypted) tunnel, thanks to pysftp, so your data is +safe!

+
+
+
+

Test connection

+
+

Checks your credentials in one click

+

Want to make sure if the connection details are correct and if Odoo can +automatically write them to the remote server? Simply click on the ‘Test +SFTP Connection’ button and you will get message telling you if +everything is OK, or what is wrong!

+
+
+
+

E-mail on backup failure

+
+

Stay informed of problems, automatically!

+

Do you want to know if the database backup succeeded or failed? Subscribe to +the corresponding backup setting notification type.

+
+
+
+

Run backups when you want

+

From the backups configuration list, press More > Execute backup(s) to +manually execute the selected processes.

+Try me on Runbot +
+
+
+

Known issues / Roadmap

+
    +
  • On larger databases, it is possible that backups will die due to Odoo server +settings. In order to circumvent this without frivolously changing settings, +you need to run the backup from outside of the main Odoo instance. How to do +this is outlined in this blog post.
  • +
  • Backups won’t work if list_db=False is configured in the instance.
  • +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Yenthe Van Ginneken
  • +
  • Agile Business Group
  • +
  • Grupo ESOC Ingenieria de Servicios
  • +
  • LasLabs
  • +
  • AdaptiveCity
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/server-tools project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/auto_backup/tests/test_db_backup.py b/auto_backup/tests/test_db_backup.py index 13aa3ff9e..a30fa9c33 100644 --- a/auto_backup/tests/test_db_backup.py +++ b/auto_backup/tests/test_db_backup.py @@ -1,6 +1,6 @@ -# © 2015 Agile Business Group -# © 2015 Alessio Gerace -# © 2016 Grupo ESOC Ingeniería de Servicios, S.L.U. - Jairo Llopis +# Copyright 2015 Agile Business Group +# Copyright 2015 Alessio Gerace +# Copyright 2016 Grupo ESOC Ingenieria de Servicios, S.L.U. - Jairo Llopis # Copyright 2016 LasLabs Inc. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). diff --git a/auto_backup/view/db_backup_view.xml b/auto_backup/view/db_backup_view.xml index ebed80c91..9b426e5b8 100644 --- a/auto_backup/view/db_backup_view.xml +++ b/auto_backup/view/db_backup_view.xml @@ -18,7 +18,7 @@
-
+

Warning:

Use SFTP with caution! This writes files to external servers under the path you specify.
diff --git a/requirements.txt b/requirements.txt index e3203d01a..ee4cb93cb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ raven openpyxl xlrd xlwt +pysftp