# Trouble with restore: "invalid command \\restrict"

**URL:** https://meta.discourse.org/t/trouble-with-restore-invalid-command-restrict/386992
**Category:** Support
**Created:** [October 28, 2025, 8:19pm UTC](https://meta.discourse.org/t/trouble-with-restore-invalid-command-restrict/386992 "2025-10-28T20:19:59Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [October 28, 2025, 8:19pm UTC](https://meta.discourse.org/t/trouble-with-restore-invalid-command-restrict/386992/1 "2025-10-28T20:19:59Z")

</div>

I’m having trouble doing a restore from “Discourse 3.5.0.beta9-dev - 04dbc622ab1e0197d16703ba47cf005ec93697ee” to current (6f06709643fa5e2253606c46f79d089ca3393ac9)

```plaintext
[STARTED]
'system' has started the restore!
Marking restore as running...
Making sure /home/pfaffman/src/discourse-repos/discourse/tmp/restores/default/2025-10-28-201139 exists...
Downloading archive to tmp directory...
Extracting dump file...
Validating metadata...
  Current version: 20251024020353
  Restored version: 20250724012518
Enabling readonly mode...
Pausing sidekiq...
Waiting up to 60 seconds for Sidekiq to finish running jobs...
Creating missing functions in the discourse_functions schema...
Restoring dump file... (this may take a while)
invalid command \restrict
EXCEPTION: psql failed: invalid command \restrict

```

If I remove these `printf` commands from database\_restorer, it works:

```plaintext
      <<~CMD
        (
          printf '%s\\n' "\\\\restrict #{nonce}"
          #{sed_command}
          printf '%s\\n' "\\\\unrestrict #{nonce}"
        ) | #{self.class.psql_command} 2>&1
      CMD

```

It looks like this commit.

[https://github.com/discourse/discourse/commit/2b6675f064c62211f231f2d57305d3bd6209b140](https://github.com/discourse/discourse/commit/2b6675f064c62211f231f2d57305d3bd6209b140)

On the version where the backup was made (a cdck docker container) I have this :

`PostgreSQL 15.13 (Debian 15.13-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit`

and this is where I’m trying to restore (dev site running pg15 on the bare metal):

`PostgreSQL 15.13 (Ubuntu 15.13-1.pgdg22.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, 64-bit`

I don’t understand what this code is trying to do, so I’m just confused.

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [October 29, 2025, 6:28am UTC](https://meta.discourse.org/t/trouble-with-restore-invalid-command-restrict/386992/2 "2025-10-29T06:28:46Z")

</div>

You need to be on PG 15.14 and you need to make sure all your instances are on that. This patches a large security issue.

> **[PostgreSQL: CVE-2025-8714: PostgreSQL pg\_dump lets superuser of origin server...](https://www.postgresql.org/support/security/CVE-2025-8714/)**

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [October 29, 2025, 11:41am UTC](https://meta.discourse.org/t/trouble-with-restore-invalid-command-restrict/386992/3 "2025-10-29T11:41:38Z")

</div>

Aha. That’s a very simple explanation.

Thanks. I’ll get on that.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [November 28, 2025, 10:11pm UTC](https://meta.discourse.org/t/trouble-with-restore-invalid-command-restrict/386992/4 "2025-11-28T22:11:00Z")

</div>

4 posts were split to a new topic: [Can’t upgrade because edited a template](https://meta.discourse.org/t/cant-upgrade-because-edited-a-template/389917)

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [December 28, 2025, 10:11pm UTC](https://meta.discourse.org/t/trouble-with-restore-invalid-command-restrict/386992/5 "2025-12-28T22:11:41Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
