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 Mi Piace

È possibile creare e scaricare questo file di backup in modo programmatico? Voglio dire, ho alcuni script cron sul server che eseguono il backup di innumerevoli altri servizi, posso eseguire alcuni comandi CLI direttamente sul server per ottenere il backup lÏ? Magari ./launcher app backup new-backup.backup o qualcosa di simile?

I backup si trovano in /var/discourse/shared/standalone/backups

Puoi avviare un backup con

./launcher run app discourse backup

Oppure

docker exec app bash -c "discourse backup"

Penso.

2 Mi Piace

È anche possibile in un ambiente di sviluppo Docker, configurato come descritto su Install Discourse for development using Docker?

Quando provo come descritto nella sezione Creare un backup sopra, ottengo l’errore 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\".

Log completo del backup fallito
[2024-09-04 15:03:39] [STARTED]
[2024-09-04 15:03:39] 'raphael.dasgupta' ha avviato il backup!
[2024-09-04 15:03:39] Marcatura del backup come in esecuzione...
[2024-09-04 15:03:39] Assicurazione che '/src/tmp/backups/default/2024-09-04-150339' esista...
[2024-09-04 15:03:39] Assicurazione che '/src/public/backups/default' esista...
[2024-09-04 15:03:39] Aggiornamento dei metadati...
[2024-09-04 15:03:39] Dumping dello schema pubblico del database...
[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 failed
[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] Pulizia...
[2024-09-04 15:03:40] Rimozione dei residui '.tar'...
[2024-09-04 15:03:40] Marcatura del backup come completato...
[2024-09-04 15:03:40] Notifica a 'raphael.dasgupta' della fine del backup...
1 Mi Piace

Sto avendo difficoltà a scaricare un backup. Quando ho cliccato sul pulsante di download, ho ricevuto un messaggio che diceva che un link per il download era stato inviato al mio indirizzo email. Tuttavia, sono passati più di due giorni e non ho ancora ricevuto l’email.

Per favore, assistimi.

hai provato ./discourse-doctor

Grazie per la tua risposta. Il problema principale è che ho configurato un’altra email dal backend come amministratore. La connessione alla porta numero 587 continua a fallire e le email non vengono inviate. C’è un modo per aggirare il problema o c’è un’altra porta da usare?

1 Mi Piace

è questa la risposta alternativa tramite indirizzo email che hai confermato?

la porta 587 è quella che uso per connettermi a smtp.eu.mailgun.org

Queste sono le impostazioni del mio server.

Capisco, quindi vuoi Office 365 sul tuo dominio principale e Discourse transactional email / mail-receiver tramite MX su un sottodominio?

SÏ, perchÊ la mia email è impostata su 365

Penso che la causa del problema sia che stai usando Office 365 per le email transazionali. Potresti voler utilizzare un servizio di posta transazionale come Mailgun o Brevo, entrambi utilizzati con Discourse senza molti problemi.

1 Mi Piace

Posso aiutarti con le configurazioni descritte. Al momento, non sarai in grado di inviare o ricevere e-mail di discourse utilizzando i tuoi abbonamenti a Office 365.

A che scala di forum stiamo parlando? un piano di posta elettronica gratuito potrebbe essere sufficiente.

Ho configurato le impostazioni SMTP utilizzando Brevo e ho utilizzato la porta 587, e sto ancora ricevendo lo stesso errore. Per favore, aiutami, non sono sicuro di dove sto sbagliando.

Hmm… che ne dici di cambiare la porta in 2525?

1 Mi Piace

sei riuscito a farlo funzionare?