Read-only flag gets reset during backup and restore to new server

I’m busy working out the process to backup our existing production site and restoring on a secondary site and then pointing our proxy to the correct back-end to allow graceful upgrading of our site without downtime.

The process so far is pretty simple. (This will be automated)

  1. Enable read-only on production site.
  2. Enable including uploads in backups.
  3. Run backup.
  4. Copy backup to standby site.
  5. Enable read-only on standby site.
  6. Restore backup with uploads.
  7. Switch proxy to standby site.
  8. Disable read-only mode on standby site.

Now the standby site is the new production site. The problem seems to be the backup process removes the read-only status, thus making production live again, which allows changes that is not included in the backup to be possible.

My expectation is the backup process should not change the read-only state of the site.
Changing this state allows for changes that will not be on the restored site.

Regards
Henti

How do you enable read-only mode? Through the button on the website?

I’ve done something similar recently and read-only mode did stick.

Hey Felix,

It’s via command line as it’ll be automated in scripts or CMS.

sudo /usr/bin/docker exec -i app discourse enable_readonly

H

In that case, you have to pass a key that identifies this read-only mode as user-selected – I’m not sure what the exact syntax is, though, maybe someone else can help :slight_smile:

2 Likes

After a bit of searching…

Try opening a rails console (./launcher enter app, rails c) and running Discourse.enable_readonly_mode(Discourse::USER_READONLY_MODE_KEY).
I haven’t tried this, so have a backup ready, but it’s a very educated guess, given the quote above ;-))

2 Likes

And now I am closer to understanding just why that verbose parameter is required. :slight_smile:

Readonly mode is based on keys stored in Redis. If you’re restoring backup from one site to another that uses a different Redis server, it is going to fall out of readonly mode.

3 Likes

Hi @tgxworld,

Thanks, that makes sense now. I’ll update my process to set the restored instance to read-only mode as soon as it’s done.

H

1 Like