Create, download, and restore a backup of your Discourse database

:bookmark: This guide provides step-by-step instructions for creating, downloading, and restoring a backup of your Discourse database.

:person_raising_hand: Required user level: Administrator

Discourse allows site administrators to create and download a copy of the site’s database. The backup can then be uploaded and restored to any Discourse forum.

Discourse backups include the full site database, which contains everything on the site: topics, posts, users, groups, settings, themes, etc. Depending on how the backup file is created, it may or may not include uploads. See the next section for details.

Though the data created by plugins exist in the database, the plugins themselves are installed in your app.yml file. To restore your site to a new server you will need to make sure that your installation includes the plugins you require.

Read-only mode

You can enable read-only mode on the Backups page to prevent site changes for admin-related tasks. Learn more about read-only mode here.

Create a backup

To create a backup of your Discourse site, follow these steps:

  1. Go to the Admin / Backups section of your site.
  2. Click the Backup button.

  1. A modal window will open asking you whether or not you would like to include the site’s uploads in the backup. Specify whether you want to include site uploads in your backup.

:warning: If your site is hosted by us and you would like to create a backup that includes uploads, contact the Discourse team before creating the backup.

  1. Initiate the backup by selecting your preferred option.

Download a backup

When the backup is complete, Discourse will send you a notification.

  • Click the link in the notification to return to your Backups page. Then click the Download button.

  • An email with a link to download the backup will be sent to you. Click the link to save the backup to your computer.

Upload a backup

  • To upload a backup, go to the Admin / Backups section of your site and click the Upload button.

  • This will open your browser’s file manager. Select the backup from your file system and click the file manager’s Open button. The new backup file will be displayed in the file list.

Restore a backup

Before you are able to restore your backup file you need to enable the allow restore site setting. Then click the Restore button on the Backups page for the backup you want to restore.

:warning: Restoring a backup file will overwrite all data on the site. When the backup is restored, you will be logged out of the site and need to log back in with your credentials from the restored site.

:warning: Make sure the site you are restoring into is running the same version of Discourse as the old site. It is best to update both sites to the latest version before running the backup/restore process.

The restore process automatically sets the disable emails setting to “non-staff”, so emails aren’t sent to your site’s users until you’re ready.

:discourse: If your site is hosted by Discourse, the Restore button in the screenshot below will be disabled. After uploading the backup file, contact the Discourse team and let us know the name of the backup file that you wish to restore. We will restore it for you.

Command line backup and restore

For administrators comfortable with the command line, you can create and manage backups programmatically:

  • Backups are stored in /var/discourse/shared/standalone/backups.
  • Start a backup using:
./launcher run app discourse backup

or

docker exec app bash -c "discourse backup"

For more information about command line backups, see: Backup discourse from the command line.

Last edited by @hugh 2025-10-03T04:56:55Z

Last checked by @hugh 2025-10-03T04:57:04Z

Check documentPerform check on document:
32 „Gefällt mir“

Gibt es eine Möglichkeit, diese Sicherungsdatei programmatisch zu erstellen und herunterzuladen? Ich meine, ich habe einige Cron-Skripte auf dem Server, die Sicherungen für unzählige andere Dienste durchführen. Kann ich direkt auf dem Server ein paar CLI-Befehle ausführen, um die Sicherung dort zu erhalten? Vielleicht so etwas wie ./launcher app backup new-backup.backup?

Die Backups befinden sich unter /var/discourse/shared/standalone/backups

Sie können ein Backup starten mit

./launcher run app discourse backup

Oder

docker exec app bash -c "discourse backup"

Ich glaube.

2 „Gefällt mir“

Ist dies auch in einer Docker-Entwicklungsumgebung möglich, die wie unter Install Discourse for development using Docker beschrieben eingerichtet ist?

Wenn ich es wie im Abschnitt Backup erstellen oben beschrieben versuche, erhalte ich den Fehler pg_dump: error: connection to database "discourse_development" failed: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: Peer authentication failed for user "postgres".

Vollständiges Protokoll des fehlgeschlagenen Backups
[2024-09-04 15:03:39] [STARTED]
[2024-09-04 15:03:39] 'raphael.dasgupta' hat das Backup gestartet!
[2024-09-04 15:03:39] Markiere Backup als laufend...
[2024-09-04 15:03:39] Stelle sicher, dass '/src/tmp/backups/default/2024-09-04-150339' existiert...
[2024-09-04 15:03:39] Stelle sicher, dass '/src/public/backups/default' existiert...
[2024-09-04 15:03:39] Metadaten aktualisieren...
[2024-09-04 15:03:39] Öffentliches Schema der Datenbank sichern...
[2024-09-04 15:03:40] pg_dump: error: connection to database "discourse_development" failed: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: Peer authentication failed for user "postgres"
[2024-09-04 15:03:40] EXCEPTION: pg_dump fehlgeschlagen
[2024-09-04 15:03:40] /src/lib/backup_restore/backuper.rb:173:in `dump_public_schema'
/src/lib/backup_restore/backuper.rb:36:in `run'
/src/script/spawn_backup_restore.rb:9:in `backup'
/src/script/spawn_backup_restore.rb:31:in `block in <main>'
/src/script/spawn_backup_restore.rb:4:in `fork'
/src/script/spawn_backup_restore.rb:4:in `<main>'
[2024-09-04 15:03:40] Aufräumen...
[2024-09-04 15:03:40] '.tar' Überbleibsel entfernen...
[2024-09-04 15:03:40] Markiere Backup als beendet...
[2024-09-04 15:03:40] Benachrichtige 'raphael.dasgupta' über das Ende des Backups...
1 „Gefällt mir“

Ich habe Schwierigkeiten, ein Backup herunterzuladen. Als ich auf die Download-Schaltfläche klickte, erhielt ich eine Aufforderung, dass ein Download-Link an meine E-Mail-Adresse gesendet wurde. Allerdings sind jetzt über zwei Tage vergangen und ich habe die E-Mail immer noch nicht erhalten.

Bitte helfen Sie mir freundlicherweise.

Haben Sie es mit ./discourse-doctor versucht

Vielen Dank für Ihre Antwort. Das Hauptproblem ist, dass ich eine andere E-Mail vom Backend als Administrator konfiguriert habe. Die Verbindung zu Port 587 schlägt immer wieder fehl und E-Mails werden nicht gesendet. Gibt es eine Möglichkeit, dies zu umgehen, oder gibt es einen anderen Port, den ich verwenden kann?

1 „Gefällt mir“

Ist dies die alternative Antwort per E-Mail-Adresse, die Sie bestätigt haben?

Port 587 ist das, was ich verwende, um eine Verbindung zu smtp.eu.mailgun.org herzustellen

Dies ist, was ich in meinen Servereinstellungen habe.

Ich verstehe, Sie möchten Office 365 auf Ihrer Root-Domain und Discourse-Transaktions-E-Mail / Mail-Empfänger über MX auf einer Subdomain?

Ja, weil meine E-Mail auf 365 eingestellt ist

Ich glaube, die Ursache des Problems ist, dass Sie Office 365 für Transaktions-E-Mails verwenden. Sie sollten einen Transaktions-E-Mail-Dienst wie Mailgun oder Brevo verwenden, die beide ohne größere Probleme mit Discourse verwendet werden.

1 „Gefällt mir“

Ich kann Ihnen bei den beschriebenen Einrichtungen helfen. Derzeit können Sie keine Discourse-E-Mails über Ihre Office 365-Abonnements senden oder empfangen.

Welchen Umfang hat das Forum, das wir hier betrachten? Ein kostenloser E-Mail-Plan könnte ausreichen.

Ich habe die SMTP-Einstellungen mit Brevo konfiguriert und Port 587 verwendet, erhalte aber immer noch dieselbe Fehlermeldung. Bitte helfen Sie mir, ich bin nicht sicher, wo ich falsch liege.

Hmm… was ist mit der Änderung des Ports auf 2525?

1 „Gefällt mir“

Konnten Sie das zum Laufen bringen?