Backup and Restore SQLite DB to server?

I’m using SQLite for my small web app, when I deploy it runs migration scripts which is great. However, I’d like to restore a copy of my local DB to the server as it has lots of data in it. Is it possible to do this?

I assume it’s possible with LiteFS but what about standard SQLite files?

On a side note, are there any nice guides on implementing LiteFS with a NextJS project? I couldn’t find anything with Google :frowning:

Hi… Yes, it is largely the same procedure. The details depend on your exact filesystem layout, but it would go something like…

$ fly sftp shell
» put local.db /tmp/local.db
» ^C

$ fly ssh console
# cd /data/
# df -h .  # double-check that this is a persistent volume.
# mv -i -v server.db old.db
# mv -i -v /tmp/local.db server.db

(Here ^C is Ctrl+C, to exit the miniature, cameo shell.)

A persistent volume will be mounted on /data (typically) as opposed to /.

Once you’re satisfied that everything is working, you can remove old.db.

Unfortunately no search engine other than Marginalia is good at niche nerdknowledge anymore, in my experience.

You may have better luck with the forum’s own search box, actually. The following looks promising, for example, albeit a bit dated…

https://community.fly.io/t/unable-to-deploy-nextjs-app-with-sqlite-db/12176

1 Like

Added litefs, sqlite, volumes

Thank you so much! That was really useful, copied my local DB across without any issue at all.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.