Hi guys, I am migrating my site from Vercel to Fly and I have created a local SQLite dump with all of my sites content. I have used fly launch
to deploy the site which is working but now I need to overwrite the SQLite db file in the persistent volume with the one I have locally. Is this possible and how would I approach it?
I probably would do it this way (kinda hacky but might do the trick):
Put your local db file to be available on some url (e.g. dropbox).
If it is possible to overwrite it while your instance is running, then you could flyctl ssh console
and just wget
it there.
But if your instance is reserving that file somehow and it is impossible to overwrite it in-place, then you could run wget
on your Dockerfile, before starting your app.
Then, when you have your file there running, you can remove that line from Dockerfile.
Do you know if its possible to FTP in and replace that way? To me that seems like the simplest solution. I asked on twitter also and fly proxy
was mentioned but I have no clue how this would work with the sqlite3 CLI to replace/import the database
@savikko I tried what you suggested but wget
doesn’t seem to be available? Do I need to do something so the command is available in the ssh console?
One potential idea is to ssh to the console and just manually install wget
.
E.G: apt-get install wget
This would get removed on your next deploy, but that’s probably fine.
If your instance is indeed reserving that file and you can’t hot-swap you could just rename the new database file and change your app to point to it. There may be an sqlite specific approach that i’m missing, but this may be easy enough.
And well, of course you could first run there just some generic linux image (not tested this method but should work):
First remove any healthchecks from your fly.toml (so that image wont end up to restart loop).
Then:
flyctl deploy -i ubuntu
That will start basic ubuntu image there.
Then flyctl ssh console
and have fun with wget
and then when you have all the files there, do flyctl deploy
I had to do this recently, and found an easy way:
In one terminal: fly proxy 10022:22
In the second terminal: scp -P 10022 local/path/to/file.db root@localhost:/remote/path/to/file.db
I recently had a similar need to push/pull files to a Fly volume for a PHP-based CMS. What I did is added wormhole-william (a single binary Go-based version of magic-wormhole) to my Dockerfile setup:
FROM php:8.0-apache
# Assorted setup…
# Install Go-based magic-wormhole for downloading volume content for local development.
RUN curl -fsSL -o /usr/local/bin/wormhole https://github.com/psanford/wormhole-william/releases/download/v1.0.6/wormhole-william-linux-amd64 && chmod +x /usr/local/bin/wormhole
# Other setup…
Then, with wormhole-william/magic-wormhole installed on my local computer, I can push a file or folder like so:
# In terminal tab A
wormhole send path/to/file
# In terminal tab B
flyctl ssh console
cd /path/to/dest
wormhole receive <code-from-tab-a>
Or I can pull a file or folder like so:
# In terminal tab A
fly ssh console -C "wormhole send /data/path/to/file"
# In terminal tab B
cd /path/to/dest
wormhole receive <code-from-tab-a>
The nice thing about this approach is it transfers directly between devices without an intermediary like Dropbox. Plus, you can use wormhole-william’s Go-based API to write a little script to automate these steps if you’re doing it often.
Clever! Reminds me of GitHub - superfly/wormhole: Fly.io secure tunnel
Btw, 6pn
with scp
works just as nicely: How to copy files off a VM - #8 by CabelloMania
From How To to Questions / Help
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.