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

Integrate Backup & Restore Feature #245

Closed
kilrau opened this issue Dec 12, 2019 · 4 comments · Fixed by #287
Closed

Integrate Backup & Restore Feature #245

kilrau opened this issue Dec 12, 2019 · 4 comments · Fixed by #287
Assignees
Labels
P1 top priority

Comments

@kilrau
Copy link
Contributor

kilrau commented Dec 12, 2019

1. Restore (depends on ExchangeUnion/xud#1041)

If there is already data in the xud's directory, try to start environment with that. If anything is corrupted, exit with an error.

If directory is empty, ask user is she wants to create a new xud environment or restore an existing one:

Do you want to create a new xud environment or restore an existing one?
1. Create New
2. Restore Existing
Please choose: 

1 - continue as of now
2 - Please paste the path to your xud backup files to restore your channel balance, your keys and other historical data: /glibberish

If backup path not valid (like above) then

Checking files... path not available. Do you wish to continue WITHOUT restoring channel balance, keys and historical data? [Y/n] N

If path does not contain any files named xud, raiden lnd-BTC or lnd-LTC OR user just pressing ENTER, then:

Checking files... no backup files found. Do you wish to continue WITHOUT restoring channel balance, keys and historical data? [Y/n] N

If backup path contains files named xud, lnd-BTC and raiden (but e.g. not lnd-LTC), then:

Checking files... Looking good. This will restore xud, lndbtc, raiden. Do you wish to continue? [Y/n] Y
BEWARE: Restoring your environment will close your existing lnd channels and restore channel balance in your wallet. Do you wish to continue? [Y/n] y

Then switch to xucli restore command output:
You are restoring an xud node key and so on.

Next step:

2. Backup (was merged in ExchangeUnion/xud#1032)

  • CLI prompt after showing generated SEED or after succesful Restore:
Please enter a path to a destination where to store a backup of your environment. It includes everything, but NOT your wallet balance which is secured by your XUD SEED. The path should be an external drive, like a USB or network drive, which is permanently available on your device since backups are written constantly.

Enter path to backup location: /media/USB/xud-backup
Checking backup location... OK.
Checking backup location... Failed. Retry? [Y/n]  N
DOWN
  • Backup path is persisted in mainnet.conf as e.g. backup-dir = "/media/USB/xud-backup" in a new [backup] section
  • On every start of xud.sh, check if backup path is set and path is available and writable. If not set, ask to set as above, if not available, additionally print
Backup location not available.
Enter path to backup location: 

There is just no way the user can get into xud ctl without specifying a functioning backup path.

Like all other command line parameters, --backup-dir CLI parameter simply overwrites whatever is written in config file.

Test cases

  1. backup-dir missing, empty network dir (first run), choose create
  • ask create or restore, user chooses create
  • interactive create (password)
  • ask user to enter backup-dir path (check if available, writable - see above)
  • enter xudctl
  1. backup-dir missing, empty network dir (first run), choose restore
  • ask create or restore, user chooses restore
  • interactive restore asking for mnemonic and backup file location (see above)
  • ask user to enter backup-dir path (check if available, writable - see above)
  • enter xudctl
  1. backup-dir set, empty network dir (first run), choose create
  • ask create or restore, user chooses create
  • interactive create (password)
  • check if backup-dir available, writable (see above)
  • enter xudctl
  1. backup-dir set, empty network dir (first run), choose restore
  • ask create or restore, user chooses restore
  • interactive restore asking for mnemonic and backup file location (see above)
  • check if backup-dir available, writable (see above)
  • enter xudctl
  1. backup-dir set, non-empty network-dir (not first run)
  • check if backup-dir available, writable (see above)
  • if yes, try to launch environment, exit with error if anything is missing
  • if no, Checking backup location... Failed. & ask user to enter backup-dir path (check if available, writable - see above)
  1. backup-dir not set, non-empty network-dir (not first run)
  • ask user to enter backup-dir path (check if available, writable - see above)
  • try to launch environment, exit with error if anything is missing
@kilrau kilrau added the P1 top priority label Dec 12, 2019
@kilrau kilrau changed the title Integrate Restore Feature Integrate Restore & Backup Feature Dec 12, 2019
@kilrau kilrau assigned sangaman and unassigned reliveyy Dec 12, 2019
@kilrau kilrau changed the title Integrate Restore & Backup Feature Integrate Channel Backup & Restore Feature Dec 12, 2019
@kilrau kilrau changed the title Integrate Channel Backup & Restore Feature Integrate Backup & Restore Feature Dec 12, 2019
@ghost
Copy link

ghost commented Dec 12, 2019

Looks good on first glance. Some thoughts:

prompt on every start if path not set or not available

If the path set is not available (invalid permissions, unmounted volume etc.) the script should exit.

Please paste the path to your backup to restore your xud environment and channel balance:

By default we could get the value from the config. If the path is not available the system should also support restoring only the wallet balances.

@ghost
Copy link

ghost commented Dec 12, 2019

what to do if there's already data in the default location

If existing data directory exists we could prompt user for confirmation to overwrite.

@kilrau kilrau mentioned this issue Jan 11, 2020
@kilrau
Copy link
Contributor Author

kilrau commented Jan 16, 2020

Issues with current version that need to be fixed:

  • we're updating the raiden database quite often, we should do that a bit less since the raiden db gets quite large (>150MB on our mainnet node)
  • fix relative --backup-dir path, e.g. bash xud.sh --backup-dir xud-backup-dir
  • bash restore prompt was faulty (only comes up on a clean / non-existent mainnet dir). It should come up with the same logic of the current create call that get triggered when it can't find xud keys. Current feat/restore implmentation put this choice in setup.sh. After moving such logic into utils the whole flow will be like this:
$ ~/xud.sh -b feat/restore --backup-dir ~/my-backup
1) Simnet
2) Testnet
3) Mainnet
Please choose the network: 3
🚀 Launching mainnet environment
🌍 Checking for updates ...
...

Would you like to create a new xud node or restore an existing one?
1) New
2) Restore
Please choose: 1/2
...

mainnet >
  • restore was taken out of 1.0.0-beta and needs to be implemented. Checking backup files BEFORE asking for mnemonic and only continue if all is well (see above)

@kilrau
Copy link
Contributor Author

kilrau commented Jan 21, 2020

@sangaman @reliveyy is taking over

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 top priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants