[edited 2019-09-27: added v
and n
flags to the cp
command to provide a verbose description of what’s happening and to not overwrite existing files; added explanation of how to disable staging afterwards]
As a Ghost newbie and fast fan, this feels like a very under-served topic, and warrants a bump.
After searching far and wide for some guides and coming up short, I rolled the dice on an idea and am fairly satisfied with it. To wit:
I created a staging environment by pointing staging.mydomain.name
at the same IP as www.mydomain.name
, and then simply following the install instructions a second time. Essentially I was able to say “yes” again to all the setup questions.
I then copied over the useful content (which amounted to just images):
sudo cp -vnpR /var/www/production-site/content/images /var/www/staging-site/content/
Then, somewhat surprisingly, used the Ghost Admin interface to copy the database via export/import: Admin → Settings → Labs → Export/Import. This produced 3 warnings, which all seem benign. Two were “User: Entry”, which warned that the duplicate entries for the Ghost user and my initial user would be ignored, and the third warned that Themes would not be imported.
That resulted in a staging.mydomain.name
which was visually identical to www.mydomain.name
. I’ve then been able to make all my experimental changes in the staging.mydomain.name
Admin interface, before copying them to www.mydomain.name
. Once done with staging, disable it by running ghost stop --disable
in the install directory (the disable flag prevents it restarting next time you reboot). You’ll be left with a “502 Bad Gateway” error if you try to browse to the staging URL, but that doesn’t seem like a big deal to me.
Initially I thought my experimentation would involve installing a custom Theme, which I was confident doing because Themes are just files on the file system, plus the selection in the database, both of which could be easily synchronised back to production. In the end it turned out my initial experimentation only needed to use Code Injection, which is even easier to synchronise back to production.
So certainly not a full blown CI/CD staging pipeline, but in my mind meets the “easy” requirement nicely!