benbjohnson / litestream

Streaming replication for SQLite.
https://litestream.io
Apache License 2.0
11.07k stars 254 forks source link

Unable to recover database from a local replica #444

Open gustingonzalez opened 1 year ago

gustingonzalez commented 1 year ago

Hi, there! I'm trying to recover a database by using the command litestream restore -o /tmp/db /path/to/replica.db. However, I'm getting the error database not found in config: /path/to/replica.db. Also, I tried it without specifying the -o parameter, with same error. I can only recover the database without specifying the replica parameter.

Am I making a mistake specifying the command?

Thanks in advance!

benbjohnson commented 1 year ago

@gustingonzalez What does your config file look like?

gustingonzalez commented 1 year ago

@benbjohnson, my config file looks like the following:

# AWS credentials
# access-key-id:     AKIAxxxxxxxxxxxxxxxx
# secret-access-key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxx

dbs:
  - path: /tmp/source.db            # Database to replicate from
    replicas:
      - path: /tmp/replica.db          # File-based replication

So, the command that I'm using is: litestream restore -o /tmp/restored.db /tmp/replica.db.

Note that, despite this, my understanding (according to the documentation) is that a config file wouldn't be required by using this command.

benbjohnson commented 1 year ago

@gustingonzalez If you're using a regular path then it'll try to match the database name. In that case, you'd need to specify:

$ litestream restore -o /tmp/restored.db /tmp/source.db

I believe you need to specify the replica in a URL format for it to skip the config:

$ litestream restore -o /tmp/restored.db file:///tmp/replica.db