Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

13.0 odoo backup sh #1114

Merged
merged 1 commit into from
May 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion odoo_backup_sh/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,4 @@ Further information
Odoo Apps Store: https://apps.odoo.com/apps/modules/13.0/odoo_backup_sh/


Tested on `Odoo 12.0 <https://github.com/odoo/odoo/commit/483b6024cd44fcc6e2b987505beb739014b51856>`_
Tested on `Odoo 13.0 <https://github.com/odoo/odoo/commit/fafea72843e25e0fee091ca935df61edb9133f6f>`_
10 changes: 4 additions & 6 deletions odoo_backup_sh/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
# Copyright 2018 Stanislav Krotov <https://it-projects.info/team/ufaks>
# Copyright 2019 Eugene Molotov <https://it-projects.info/team/molotov>
# Copyright 2019 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# Copyright 2021 Denis Mudarisov <https://github.com/trojikman>
# License MIT (https://opensource.org/licenses/MIT).
{
"name": """S3 backing up""",
"summary": """Yet another backup tool, but with sexy graphs""",
"category": "Backup",
# "live_test_url": "",
"images": ["images/odoo-backup.sh.jpg"],
"version": "13.0.1.0.2",
"version": "13.0.1.0.3",
"author": "IT-Projects LLC",
"support": "apps@itpp.dev",
"website": "https://apps.odoo.com/apps/modules/13.0/odoo_backup_sh/",
"support": "help@itpp.dev",
"website": "https://twitter.com/OdooFree",
"license": "Other OSI approved licence", # MIT
# "price": 1.00,
# "currency": "EUR",
"depends": ["iap", "mail"],
"external_dependencies": {
"python": ["boto3", "botocore", "pretty_bad_protocol"],
Expand Down
4 changes: 4 additions & 0 deletions odoo_backup_sh/doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
`1.0.3`

- **Fix:** Add parameter to control all the databases while keeping /web/database/manager page hidden

`1.0.2`
-------

Expand Down
16 changes: 14 additions & 2 deletions odoo_backup_sh/models/odoo_backup_sh.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2018 Stanislav Krotov <https://it-projects.info/team/ufaks>
# Copyright 2019 Dinar Gabbasov <https://it-projects.info/team/GabbasovDinar>
# Copyright 2019 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# Copyright 2021 Denis Mudarisov <https://github.com/trojikman>
# License MIT (https://opensource.org/licenses/MIT).

import copy
Expand Down Expand Up @@ -42,6 +43,10 @@
BACKUP_NAME_SUFFIX = ".zip"
BACKUP_NAME_ENCRYPT_SUFFIX = BACKUP_NAME_SUFFIX + ".enc"
S3_STORAGE = "odoo_backup_sh"
# Replace to True if you want to control all the databases while keeping /web/database/manager page hidden
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Надо еще предупреждение добавить какое-нибудь типа:

Warning: if you use this module in sort of saas platform with many databases, be sure that unauthorized users cannot install this module in their database and get dump of any database

# Warning: if you use this module in sort of saas platform with many databases, be sure that unauthorized users cannot
# install this module in their database and get dump of any database
FORCE_ALL_DATABASE = False


def compute_backup_filename(database, upload_datetime, is_encrypted):
Expand Down Expand Up @@ -91,7 +96,9 @@ class BackupConfig(models.Model):

@api.model
def _compute_database_names(self):
if odoo.tools.config["list_db"]:
if FORCE_ALL_DATABASE:
return [(db, db) for db in odoo.service.db.list_dbs(force=True)]
elif odoo.tools.config["list_db"]:
return [
(db, db) for db in odoo.service.db.list_dbs() if db != "session_store"
]
Expand Down Expand Up @@ -631,8 +638,13 @@ def get_dump_stream_and_info_file(self, name, service, ts):
if config_record.backup_simulation:
dump_stream = tempfile.TemporaryFile()
else:
dump_stream = odoo.service.db.dump_db(name, None, "zip")
if FORCE_ALL_DATABASE:
from unittest.mock import patch

with patch.dict(odoo.tools.config.options, {"list_db": True}):
dump_stream = odoo.service.db.dump_db(name, None, "zip")
else:
dump_stream = odoo.service.db.dump_db(name, None, "zip")
if config_record.encrypt_backups and config_record.backup_simulation is False:
# GnuPG ignores the --output parameter with an existing file object as value
backup_encrpyted = tempfile.NamedTemporaryFile()
Expand Down