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

add restoredb command #57

Merged
merged 5 commits into from
Oct 1, 2020
Merged

add restoredb command #57

merged 5 commits into from
Oct 1, 2020

Conversation

lmignon
Copy link
Member

@lmignon lmignon commented Oct 11, 2019

fixes #32
includes #58

@codecov-io
Copy link

codecov-io commented Oct 11, 2019

Codecov Report

Merging #57 into master will decrease coverage by 1.22%.
The diff coverage is 76.47%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #57      +/-   ##
==========================================
- Coverage   93.84%   92.61%   -1.23%     
==========================================
  Files          13       14       +1     
  Lines         763      826      +63     
  Branches      126      135       +9     
==========================================
+ Hits          716      765      +49     
- Misses         32       43      +11     
- Partials       15       18       +3     
Impacted Files Coverage Δ
click_odoo_contrib/restoredb.py 70.37% <70.37%> (ø)
click_odoo_contrib/_dbutils.py 100.00% <100.00%> (ø)
click_odoo_contrib/backupdb.py 100.00% <100.00%> (ø)
click_odoo_contrib/copydb.py 97.43% <100.00%> (+0.06%) ⬆️
click_odoo_contrib/manifest.py 100.00% <0.00%> (+2.89%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 90b8b47...67d56f2. Read the comment docs.

@lmignon lmignon force-pushed the master-add-restordb-command branch 6 times, most recently from 68f41cf to b788821 Compare October 12, 2019 09:58
@Olivier-LAURENT
Copy link

Tested by file (not by folder) with success. Thanks, 👍

@sbidoul sbidoul added the enhancement New feature or request label Nov 1, 2019
Copy link
Member

@rousseldenis rousseldenis left a comment

Choose a reason for hiding this comment

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

Functional review! LGTM

@GSLabIt
Copy link

GSLabIt commented Feb 25, 2020

@lmignon is this ready to merge?

@lmignon
Copy link
Member Author

lmignon commented Mar 2, 2020

@GSLabIt IMO yes it is. I'll resolve the conflicts into the next days

@lmignon lmignon force-pushed the master-add-restordb-command branch 2 times, most recently from 82f8529 to 23900a2 Compare March 3, 2020 10:56
@lmignon
Copy link
Member Author

lmignon commented Mar 3, 2020

@sbidoul @GSLabIt rebased and ready to merge

@sbidoul
Copy link
Member

sbidoul commented Mar 3, 2020

@lmignon don't we need to finish #58 first?

@lmignon
Copy link
Member Author

lmignon commented Mar 3, 2020

@lmignon don't we need to finish #58 first?

indeed

@lmignon lmignon force-pushed the master-add-restordb-command branch 2 times, most recently from ce3cebf to 13b5ada Compare May 3, 2020 09:14
@lmignon
Copy link
Member Author

lmignon commented May 3, 2020

@sbidoul #58 finished

@lmignon lmignon force-pushed the master-add-restordb-command branch from 13b5ada to 67d56f2 Compare May 12, 2020 14:57
@GSLabIt
Copy link

GSLabIt commented May 27, 2020

@sbidoul any news on this? ready to merge? thx

@GSLabIt
Copy link

GSLabIt commented Jul 3, 2020

hi all, any chance to get this merged? thx

@lmignon
Copy link
Member Author

lmignon commented Jul 6, 2020

@GSLabIt thank you for the reminder. This PR will be merged into the next weeks... we're a bit overloaded at the moment which leaves us little time to finalize the various reviews in progress.

@GSLabIt
Copy link

GSLabIt commented Jul 6, 2020

@lmignon thx for the feedback, looking forward for the merge.

@rousseldenis
Copy link
Member

@lmignon @sbidoul We need to ask user or to add an option to erase filestore directory. As if it exists, the command raises an error.

@rousseldenis
Copy link
Member

@lmignon @sbidoul We need to ask user or to add an option to erase filestore directory. As if it exists, the command raises an error.

But maybe in a ROADMAP so we can move forward on this

@voronind
Copy link
Contributor

Raises error in Odoo 10.0

Traceback (most recent call last):
  File "/home/voronin/.local/share/virtualenvs/sintez_addons-7QRHjYmJ/lib/python2.7/site-packages/click_odoo/env_options.py", line 218, in _invoke
    return self.org_invoke(ctx)
  File "/home/voronin/.local/share/virtualenvs/sintez_addons-7QRHjYmJ/lib/python2.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/voronin/.local/share/virtualenvs/sintez_addons-7QRHjYmJ/lib/python2.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/voronin/.local/share/virtualenvs/sintez_addons-7QRHjYmJ/src/click-odoo-contrib/click_odoo_contrib/restoredb.py", line 109, in main
    _restore_from_file(dbname, backup, copy)
  File "/home/voronin/.local/share/virtualenvs/sintez_addons-7QRHjYmJ/src/click-odoo-contrib/click_odoo_contrib/restoredb.py", line 54, in _restore_from_file
    odoo.service.db.restore_db(dbname, backup_file, copy)
  File "/home/voronin/.local/share/virtualenvs/sintez_addons-7QRHjYmJ/lib/python2.7/site-packages/odoo/service/db.py", line 262, in restore_db
    if odoo.tools.exec_pg_command(pg_cmd, *pg_args):
  File "/home/voronin/.local/share/virtualenvs/sintez_addons-7QRHjYmJ/lib/python2.7/site-packages/odoo/tools/misc.py", line 123, in exec_pg_command
    rc = subprocess.call(args2, env=env, stdout=dn, stderr=subprocess.STDOUT)
  File "/usr/lib/python2.7/subprocess.py", line 172, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.7/subprocess.py", line 394, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1047, in _execute_child
    raise child_exception
TypeError: coercing to Unicode: need string or buffer, file found```

@lmignon
Copy link
Member Author

lmignon commented Aug 27, 2020

Raises error in Odoo 10.0

Thank you @voronind for the report. Unfortunately, it is very difficult to start investigating a potential problem with only a stack-trace 😏 Can you provide more information on how you use the script. On my side, I've been using it without any problem for months also on Odoo 10.

Regards

@voronind
Copy link
Contributor

voronind commented Aug 27, 2020 via email


def _restore_from_file(dbname, backup, copy=True):
with db_management_enabled(), open(backup, "rb") as backup_file:
odoo.service.db.restore_db(dbname, backup_file, copy)
Copy link
Contributor

Choose a reason for hiding this comment

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

Odoo 10 wants file path here? Not file object.

@lmignon
Copy link
Member Author

lmignon commented Aug 27, 2020

I try restore Odoo Postgres Dump (not Zip with files). And AFAIK odoo.tools.exec_pg_command get file object instead of string with file path.

@voronind there is probably a misunderstanding in the way of using the script. The input must be a path to an Odoo backup zip file or a path to a backup directory created by the click-odoo-backupdb command.

@voronind
Copy link
Contributor

I try restore Odoo Postgres Dump (not Zip with files). And AFAIK odoo.tools.exec_pg_command get file object instead of string with file path.

@voronind there is probably a misunderstanding in the way of using the script. The input must be a path to an Odoo backup zip file or a path to a backup directory created by the click-odoo-backupdb command.

Then I request feature. Restore Odoo backup dump file.

@lmignon
Copy link
Member Author

lmignon commented Aug 27, 2020

Then I request feature. Restore Odoo backup dump file.

@voronind You're welcome to contribute to this PR

@elvise
Copy link

elvise commented Sep 2, 2020

Hi guys what's the status of this ?

@sbidoul
Copy link
Member

sbidoul commented Sep 5, 2020

Hi folks, sorry for the delay with this PR. I hope come back to it in the next month or so, unless @lmignon beats me to it :)

@codecov-commenter
Copy link

codecov-commenter commented Sep 30, 2020

Codecov Report

Merging #57 into master will decrease coverage by 1.53%.
The diff coverage is 73.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #57      +/-   ##
==========================================
- Coverage   94.15%   92.62%   -1.54%     
==========================================
  Files          13       14       +1     
  Lines         770      827      +57     
  Branches      127      135       +8     
==========================================
+ Hits          725      766      +41     
- Misses         31       43      +12     
- Partials       14       18       +4     
Impacted Files Coverage Δ
click_odoo_contrib/restoredb.py 70.37% <70.37%> (ø)
click_odoo_contrib/backupdb.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 450e70f...18ddc0f. Read the comment docs.

@sbidoul
Copy link
Member

sbidoul commented Sep 30, 2020

Rebased. If green tomorrow I'll merge and release.

@sbidoul sbidoul merged commit 10ad6ae into master Oct 1, 2020
@acsone-git-bot acsone-git-bot deleted the master-add-restordb-command branch October 1, 2020 06:50
@sbidoul
Copy link
Member

sbidoul commented Oct 1, 2020

@rousseldenis @voronind I'm going to release this as is, I think it is good enough. If you have identified issues or missing feature, can you please open separate issues to discuss them ?

@GSLabIt
Copy link

GSLabIt commented Oct 1, 2020

@sbidoul pip package will be released as well?

@sbidoul
Copy link
Member

sbidoul commented Oct 1, 2020

The release is on it's way to PyPI, as soon as travis catches up: https://travis-ci.com/github/acsone/click-odoo-contrib/builds/187542839

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

restoredb
10 participants