Backup and restore Ursula config#2682
Backup and restore Ursula config#2682piotr-roslaniec wants to merge 10 commits intonucypher:mainfrom
Conversation
|
If there are multiple ursulas on a system, how does the backup/restore functionality determine which database to use? Are we making this distinction at all, or are we inadvertently reusing a single DB for all ursulas on one host? |
|
@KPrasch There is no distinction made between databases, backups are made only based on the path to the worker directory. But this is something that can be improved by reading |
| pychalk==2.0.1 | ||
| pycparser==2.20; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' | ||
| pycryptodome==3.9.9 | ||
| pycryptodomex==3.10.1 |
There was a problem hiding this comment.
I'm wondering if there can be any implication of having both pycryptodome and pycryptodomex. It seems the x version was released to avoid interference with the pycrypto package, which we don't use anyway (https://www.pycryptodome.org/en/latest/src/introduction.html?highlight=pycryptodomex#pycryptodome). It seems in our case we can potentially use both, but probably it's a dependency issue?
There was a problem hiding this comment.
We use both of those packages as indirect dependencies of eth-hash and pyzipper. AFAIK there should be no issues with dependency shadowing, even if we start using them directly, as they have different namespaces (base package names).
|
We'll also need to add some documentation. |
f4d3ff2 to
ee8c6ec
Compare
derekpierre
left a comment
There was a problem hiding this comment.
Good stuff - just some minor documentation edits
nucypher/cli/commands/ursula.py
Outdated
| with pyzipper.AESZipFile(backup_options.backup_path) as zf: | ||
| zf.setpassword(backup_options.password) | ||
| zf.setencryption(**BACKUP_ENCRYPTION_SETTINGS) | ||
| _extract_zf(emitter, zf, KEYSTORE_ARCHIVE_ROOT, backup_options.keystore_path, backup_options.overwrite) |
There was a problem hiding this comment.
👍 - "extract" looks good there.
Co-authored-by: Derek Pierre <derek.pierre@gmail.com>
261ce7b to
df91bdc
Compare
| def _prompt_overwrite(path: Path, force: bool): | ||
| if path.exists(): | ||
| prompt = f"Path already exists: {path.absolute()}" | ||
| if force: |
derekpierre
left a comment
There was a problem hiding this comment.
Having some issues with restore and pre-existing folders.
derek @ Dereks-MacBook-Pro-2 ~/Documents/Github/repos/forks/piotr/nucypher
[37] → nucypher ursula backup --password llamallama --force
WARNING: Force is enabled
Path already exists: /Users/derek/Documents/Github/repos/forks/piotr/nucypher/ursula-backup.zip - Overwriting.
Wrote /Users/derek/Library/Application Support/nucypher
Wrote /Users/derek/Library/Ethereum/keystore
Backup created at /Users/derek/Documents/Github/repos/forks/piotr/nucypher/ursula-backup.zip
(nucypher) (base)
derek @ Dereks-MacBook-Pro-2 ~/Documents/Github/repos/forks/piotr/nucypher
[38] → ls -l worker keystore
keystore:
total 0
drwxr-xr-x 3 derek staff 96 3 Jun 09:29 keystore
worker:
total 0
drwxr-xr-x 3 derek staff 96 3 Jun 09:23 worker
(nucypher) (base)
derek @ Dereks-MacBook-Pro-2 ~/Documents/Github/repos/forks/piotr/nucypher
[39] → nucypher ursula restore --password llamallama --worker-path ./worker --keystore-path ./keystore/ --backup-path ./ursula-backup.zip
Path already exists: /Users/derek/Documents/Github/repos/forks/piotr/nucypher/keystore - Overwrite? [y/N]: y
Traceback (most recent call last):
File "/Users/derek/.local/share/virtualenvs/nucypher-GD4zeyIP/bin/nucypher", line 33, in <module>
sys.exit(load_entry_point('nucypher', 'console_scripts', 'nucypher')())
File "/Users/derek/.local/share/virtualenvs/nucypher-GD4zeyIP/lib/python3.7/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/Users/derek/.local/share/virtualenvs/nucypher-GD4zeyIP/lib/python3.7/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/Users/derek/.local/share/virtualenvs/nucypher-GD4zeyIP/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/derek/.local/share/virtualenvs/nucypher-GD4zeyIP/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/derek/.local/share/virtualenvs/nucypher-GD4zeyIP/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/derek/.local/share/virtualenvs/nucypher-GD4zeyIP/lib/python3.7/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/Users/derek/Documents/Github/repos/forks/piotr/nucypher/nucypher/cli/options.py", line 169, in wrapper
return func(**kwargs)
File "/Users/derek/Documents/Github/repos/forks/piotr/nucypher/nucypher/cli/options.py", line 169, in wrapper
return func(**kwargs)
File "/Users/derek/Documents/Github/repos/forks/piotr/nucypher/nucypher/cli/commands/ursula.py", line 600, in restore
_extract_zf(emitter, zf, KEYSTORE_ARCHIVE_ROOT, backup_options.keystore_path, backup_options.force)
File "/Users/derek/Documents/Github/repos/forks/piotr/nucypher/nucypher/cli/commands/ursula.py", line 616, in _extract_zf
shutil.move(str(archive_path.absolute()), str(destination_path.absolute()))
File "/Users/derek/.local/share/virtualenvs/nucypher-GD4zeyIP/lib/python3.7/shutil.py", line 564, in move
raise Error("Destination path '%s' already exists" % real_dst)
shutil.Error: Destination path '/Users/derek/Documents/Github/repos/forks/piotr/nucypher/keystore/keystore' already exists
Type of PR:
Required reviews:
What this does:
ursula backupandursula restore.ursula backup --worker-pathwould denote file sources used to create a backup file. On the other hand,ursula restore --worker-pathdenotes the destination where unpacked backup files will be stored.Issues fixed/closed:
Why it's needed:
Notes for reviewers:
magic-wormhole. I can implement it in another PR.