Skip to content

About

Bring a Laravel Sail project's database and files into Lerd

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sail import for Lerd

Move a Laravel Sail project to Lerd with its data. One command lifts the database and the files out of Sail's Docker stack and into Lerd, and puts Sail back the way it was.

License: MIT Lerd plugin Lerd 1.38+ Reddit Discord

lerd sail:import moving a Sail project's database and files into Lerd

A Sail project links to Lerd in a minute, but its data stays behind in Sail's containers. This plugin starts only Sail's database and storage, on ports clear of Lerd's so both run side by side, copies the database into the site's Lerd database and the files into its Lerd bucket, and stops Sail again. Sail's app image is never built, so a broken sail build cannot get in the way, and docker-compose.yml is left untouched if you ever want to go back.

Install

lerd plugin install sail

Use

Link the project and let Lerd set up its env first, then import:

cd ~/code/shop
lerd link && lerd env
lerd sail:import

It is also in the site's Commands menu in the dashboard as Import from Sail, and AI assistants get it as sail_import through Lerd's MCP server. The full instructions are on the plugin's Documentation tab in the dashboard.

Option Meaning
--db-name The Sail database, when Sail holds several
--db-user, --db-password Sail's database login, when it is not the one in the compose file
--bucket The MinIO or RustFS bucket to copy, when it is not AWS_BUCKET
--skip-s3 Leave the files alone and import the database only
--no-stop Leave Sail running afterwards
--yes Don't ask before replacing the Lerd database

What it does

  • Reads the compose file with Sail's original settings from .env.before_lerd, the copy Lerd keeps when it rewrites .env, so it finds Sail's database and bucket even after the project moved to Lerd.
  • Moves every port Lerd already uses up by 20000 (3306 becomes 23306) and leaves out the app's ports.
  • Works with MySQL, MariaDB and PostgreSQL, and with RustFS or the MinIO older Sail projects ran.
  • Takes a before-sail-import snapshot of the site's Lerd database before it imports, so lerd db:restore undoes the import.
  • Copies the files with lerd s3:import into the site's Lerd bucket.

What it reads, changes and sends

It reads the project's compose file, and .env.before_lerd or .env for Sail's database and S3 settings. It starts and stops the project's own Sail containers through docker compose or podman compose and runs nothing else. It replaces the site's Lerd database, after the snapshot, and writes Sail's files into the site's Lerd bucket. The dump and a copy of the compose file with moved ports pass through tmp/ in the plugin's data folder and are deleted afterwards. Nothing leaves your machine.

Requirements

  • Lerd 1.38 or newer, and Node, which Lerd installs
  • docker compose or podman compose, which Sail needs anyway. With Podman, docker compose talks to it through its socket: systemctl --user start podman.socket
  • MinIO no longer publishes its images, so an older Sail project whose MinIO image is not already on the machine cannot start it; import the database alone with --skip-s3

Development

node --test test/
lerd plugin install .

License

MIT

About

Bring a Laravel Sail project's database and files into Lerd

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages