Regardless of if you’re a moderator or an admin, you will no doubt at some time think about making some change to your live site and wonder if this will bring shame on you, and/or cause yourself an enormous amount of work to put right again.
There is an easy solution to this: build yourself a sandbox! You can restore a backup of your live site to the sandbox and this will give you a representative post and user base, then you can play Dangerous Dan all you want.
(If it isn’t your site, then talk to the admin/site owner first, and make sure they are ok with you cloning the site.)
All you need is:
- A host, preferably with the same OS as your live install.
- A mail provider (at least temporarily for the setup)
- The 30 minute install instructions
- A backup of your live site.
I used a free tier AWS instance, and installed Ubuntu 16.04. I increased the size of the disk as it was too small to handle restoring the 4.5GB backup. I didn’t bother setting up a domain or encryption, or https. Just a straight box that I could reach via putty and a browser.
I used AWS for this as well, I only wanted mail to complete the discourse setup and verify that the setup actually worked. The last thing I wanted was my sandbox to start sending emails out to our users. You could probably skip setting up email entirely.
SSH into the box
apt-get install htop
dpkg-reconfigure -plow unattended-upgrades
When the box comes back up check if the login message says “a restart is required” (keep an eye out for this whenever you SSH into the box)
Follow the excellent Simple 30 minute basic install
Once the box is up and you’ve complete the web part of the setup, received your email, used that to login to the website, run a backup.
SSH into the box
Make a copy of your app.yml
sudo -s cd /var/discourse/containers cp app.yml LIVEapp.yml nano app.yml
add “NOT-” to the beginning of the SMTP variables (to make sure that your sandbox won’t be able to send emails unless you change those settings again):
DISCOURSE_SMTP_ADDRESS: NOT-email... DISCOURSE_SMTP_PORT: 587 DISCOURSE_SMTP_USER_NAME: NOT-... DISCOURSE_SMTP_PASSWORD: NOT-...
save the file and exit nano (Ctrl-o, enter, Ctrl-x)
Rebuild the app:
cd /var/discourse git pull ./launcher rebuild app
When the rebuild is finished check that you can still reach the website and login etc.
Back in the CLI:
- check how much disk space you have (and note it down somewhere)
- check how your RAM usage is (and note it down somewhere)
- Have a gander at htop to see what an unloaded blank install looks like
- f10 or Ctrl-c to exit htop
In the GUI go to
sitename/admin/site_settings/category/backups and set a checkmark on “allow restore”
Visit your live site and download a recent backup (including uploads) from /admin/backups.
Go to /admin/backups and upload the backup.
Back in the CLI check how much space you have with free-h, IIRC the restore needs about 3x the size of the backup to complete without crashing because your disk is full. If in doubt, fix that now.
Restore the backup to your sandbox site.
While the restore is running, watch what is going on with htop and df-h (it’s a geek thing).
When the restore is complete, goto /admin/settings and change the following:
“disable emails” set a check mark.
Look through all of the settings (use “Only show overridden”) and change any site settings related to S3, CDNs, CSS, permalinks etc so you won’t be interfering (or masquerading) as your live site.
Back in the CLI:
./launcher rebuild app
You don’t really need to do it, but as you may have noticed, I’m a belt and braces kind of a guy, so…
When it comes back up you should have a functioning site with content, but you won’t be able to login with your live credentials.
SSH into the sandbox
sudo -s cd /var/discourse ./launcher enter app rake admin:create
Answer the questions. You can either set a password for your live account, or create a new admin (I used firstname.lastname@example.org as an email).
Now you can login to the sandbox GUI with the email and password you just set.
The last thing to do is add the plugins which your live site has to your app.yml, then ./launcher rebuild app one last time, then configure any plugin settings as your live site has.
You now have a working sandbox to play with, including content, And damned be him that first cries, “Hold, enough!”.