How I Use Craft Scripts in Craft CMS Running in Craft Nitro 2
In this article, I explain how I use Craft Scripts in my Nitro 2 local development environment to pull down user-generated assets and the Craft database from a remote Craft CMS production environment.
Assumptions
Craft 3.6.x running in in Craft Nitro 2.0.8 in a local development environment. The instructions below may or may not work in earlier and/or later versions of Craft and/or Nitro 2.x.
Craft Scripts 1.2.13, or later.
Instructions
From your Craft project's root directory on your host machine, run:
nitro ssh --rootto SSH into project's container as the root user.apk add bashto install the Alpine Linux bash shell package.apk add rsyncto install the Alpine Linux rsync package.apk add openssh-clientto install the Alpine Linux OpenSSH client package.exitto exit as root user.nitro sshto ssh into container.bash pull_assets.sh, from yourscriptsdirectory to pull down assets from remote production/staging environment.bash pull_db.shfrom within yourscriptsdirectory to pull down the Craft database from remote production/staging environment.
System changes made as the root user are ephemeral, so you'll need to repeat steps 1-4 every time Nitro recreates the site's container after you run nitro apply, nitro xon|xoff, or nitro update.
That's it! By following the steps above, I can pull down user-generated assets and the Craft database from a remote Craft CMS production environment into my Nitro 2 local development environment.

