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 backup and restore functionality #65

Merged
merged 4 commits into from
Apr 25, 2024
Merged

Add backup and restore functionality #65

merged 4 commits into from
Apr 25, 2024

Conversation

hydra-yse
Copy link
Member

@hydra-yse hydra-yse commented Mar 29, 2024

Closes #5, closes #80, closes #42.

This PR aims at giving the user the ability to backup their pending swaps in order to be able to recover and claim them across instances. Since the swap details cannot be modified across instances, the logic just needs to account for inserting non-existent swaps back to the local database. Also, we should check whether funds have already been claimed/sent, and resolve the swaps accordingly.

TODO:

@hydra-yse hydra-yse requested a review from ok300 March 29, 2024 03:23
@hydra-yse hydra-yse self-assigned this Mar 29, 2024
lib/src/wallet.rs Outdated Show resolved Hide resolved
cli/src/commands.rs Outdated Show resolved Hide resolved
lib/src/lib.rs Outdated Show resolved Hide resolved
lib/src/wallet.rs Outdated Show resolved Hide resolved
lib/src/wallet.rs Outdated Show resolved Hide resolved
lib/src/wallet.rs Outdated Show resolved Hide resolved
lib/src/wallet.rs Outdated Show resolved Hide resolved
lib/src/wallet.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@ok300 ok300 left a comment

Choose a reason for hiding this comment

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

restore_from_backup shouldn't need to know the schema IMO.

I did some research and based on

restore could be something like

fn restore_db(backup_path: &str, dest_path: &str) -> Result<()> {
    let src_conn = Connection::open(backup_path)?;
    let dest_conn = Connection::open(dest_path)?;

    let backup = Backup::new(&src_conn, &dest_conn)?;
    backup.run_to_completion(5, std::time::Duration::from_millis(250), None)?;

    Ok(())
}

fn main() -> Result<()> {
    restore_db("backup_database.db", "restored_database.db")?;
    Ok(())
}

What do you think, would that be a good solution?

lib/Cargo.toml Outdated Show resolved Hide resolved
yse added 4 commits April 24, 2024 17:14
@hydra-yse hydra-yse merged commit ecc211e into main Apr 25, 2024
2 checks passed
@hydra-yse hydra-yse deleted the yse-restore branch July 1, 2024 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sync/restore doc: add section on how to backup / restore lib: Add restore functionality
2 participants