Database backup and restore
It's not necessarily clear to our users that we're doing backups automatically. Also, there's no way for them to restore from a backup either.
If we need to restore a backup, can you contact support to have it done?
@jetaggart Yes you can. You can either reach out to us on Discord.
I want to get an SQLite file every 24 hours to perform analytics queries for BI dashboards.
~Is there a way we can programmatically create a backup?~ ~(Or a way to visualize what backups you folks have created/how often those are created?)~
~From the CLI or/and endpoints?~
NVM, this should work, right?
turso db shell MY_DATABASE .dump > dumpfile.sql
@fforres Yes, the dump should work fine. We do want to improve the developer experience, of course.
Dump and load is mentioned in the reference documentation. And yes, we can definitely do better as @penberg says.
In the documentation, I only found related commands to "load", but nothing about "dump" 🤔
Mentions of loading are here: https://docs.turso.tech/cli/db/create
--from-dump Create the database from a local SQLite dump.
--from-dump-url Create the database from a remote SQLite dump.
But there is nothing about how to "dump", move the data from the remote database to the local computer.
I found out that this worked for me to get a dump, it would be nice to have it documented I think!
turso db shell MY_DATABASE .dump > dumpfile.sql
Hey @Jolg42
I've added the load and dump examples to this page in the docs. It was left out in our recent docs update but now should be covered.
That's super nice @notrab thanks!
Also, the platform API lets the user to upload a dump from an url, but does not offer a way to make a dump. Can this be added?
Hey @GustavoOS
This currently is a database feature that isn't yet available through the Platform API. I'm not sure if it will be any time soon, we'd likely want to make it more robust. I will document the current behaviour in our new libsql docs though.
You should be able to do this:
const response = await fetch('https://your-db-url.turso.io/dump', {
headers: {
Authorization: `Bearer [DATABASE_OR_GROUP_TOKEN_HERE]`,
},
});
if (response.ok) {
const text = await response.text();
return new Response(text);
}
Good to know it is a mapped feature. But I tested it with a small database, and this was the response I got { "error": "Replicator error: Timeout performing handshake with primary" }