Migrate a c-lightning database from SQLite to Postgres!
Because Postgres is very good, it supports remote access, simultaneous readers and writers, it can replicate writes with instances elsewhere, so your channels are safer. Everything is better.
- Download the release corresponding to the database version of your
lightningd.sqlite3
file. To find out what is your version, runsqlite3 ~/.lightning/bitcoin/lightningd.sqlite3 'select version from version'
. If there's no release corresponding to your version, upgrade to the newestmaster
and ping me so I can make a new release with the latest changes. - Your c-lightning should be compiled with support for PostgreSQL. That happens automatically if you have libpq installed.
- Create a database on Postgres.
- Stop your c-lightning daemon:
lightning-cli stop
. - Run
mcldsp -sqlite=/home/user/.lightning/bitcoin/lightningd.sqlite3 -lightningd=(which lightningd) -postgres='postgres:https:///myclightningdatabase?sslmode=disable'
(replace with your actual values). - Change your
~/.lightning/config
file, add awallet=postgres:https:///myclightningdatabase
there so the next time it starts it will use the PostgreSQL database and not the SQLite file. - Start
lightningd
again and check if everything works. - Delete
mcldsp
so you never run it again. - Delete your
lightningd.sqlite
file so you don't try to use it again.
If you want to setup replication go over to https://github.com/gabridome/docs/blob/master/c-lightning_with_postgresql_reliability.md