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 إعجابًا

هل هناك طريقة لإنشاء وتنزيل ملف النسخ الاحتياطي هذا برمجيًا؟ أعني، لدي بعض نصوص cron على الخادم تقوم بعمل نسخ احتياطية للعديد من الخدمات الأخرى، هل يمكنني إصدار بعض أوامر CLI مباشرة على الخادم للحصول على النسخة الاحتياطية هناك؟ ربما ./launcher app backup new-backup.backup أو شيء من هذا القبيل؟

النسخ الاحتياطي موجود في /var/discourse/shared/standalone/backups

يمكنك بدء النسخ الاحتياطي باستخدام

./launcher run app discourse backup

أو

docker exec app bash -c "discourse backup"

أعتقد.

إعجابَين (2)

هل هذا ممكن أيضًا في بيئة تطوير Docker، تم إعدادها كما هو موضح في https://meta.discourse.org/t/install-discourse-for-development-using-docker/102009؟

عندما أحاول كما هو موضح في قسم إنشاء نسخة احتياطية أعلاه، أحصل على الخطأ 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:39] [STARTED]
[2024-09-04 15:03:39] 'raphael.dasgupta' has started the backup!
[2024-09-04 15:03:39] Marking backup as running...
[2024-09-04 15:03:39] Making sure '/src/tmp/backups/default/2024-09-04-150339' exists...
[2024-09-04 15:03:39] Making sure '/src/public/backups/default' exists...
[2024-09-04 15:03:39] Updating metadata...
[2024-09-04 15:03:39] Dumping the public schema of the 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] Cleaning stuff up...
[2024-09-04 15:03:40] Removing '.tar' leftovers...
[2024-09-04 15:03:40] Marking backup as finished...
[2024-09-04 15:03:40] Notifying 'raphael.dasgupta' of the end of the backup...
إعجاب واحد (1)

أواجه صعوبة في تنزيل نسخة احتياطية. عندما نقرت على زر التنزيل، تلقيت رسالة تفيد بأنه تم إرسال رابط تنزيل إلى عنوان بريدي الإلكتروني. ومع ذلك، لقد مر أكثر من يومين الآن وما زلت لم أستلم البريد الإلكتروني.

يرجى التكرم بالمساعدة.

هل جربت ./discourse-doctor

شكراً على ردك. المشكلة الرئيسية هي أنني قمت بتكوين بريد إلكتروني آخر من الواجهة الخلفية كمسؤول. فشل الاتصال برقم المنفذ 587 باستمرار، ولا يتم إرسال رسائل البريد الإلكتروني. هل هناك طريقة لتجاوز ذلك، أم أن هناك منفذًا آخر لاستخدامه؟

إعجاب واحد (1)

هل هذا هو الرد البديل عبر البريد الإلكتروني الذي أكدته؟

المنفذ 587 هو الذي أستخدمه للاتصال بـ smtp.eu.mailgun.org

هذه هي إعدادات الخادم لدي.

حسنًا، إذًا تريد Office 365 على نطاقك الأساسي و Discourse transactional email / mail-receiver بواسطة MX على نطاق فرعي؟

نعم، لأن بريدي الإلكتروني مُعد على 365

أعتقد أن سبب المشكلة هو استخدامك لـ Office 365 للبريد الإلكتروني للمعاملات. قد ترغب في استخدام خدمة بريد إلكتروني للمعاملات مثل Mailgun أو Brevo، وكلاهما يُستخدم مع Discourse دون مشاكل كبيرة.

إعجاب واحد (1)

يمكنني مساعدتك في الإعدادات الموصوفة. في الوقت الحالي، لن تتمكن من إرسال أو استقبال رسائل البريد الإلكتروني الخاصة بـ discourse باستخدام اشتراك (اشتراكات) Office 365 الخاص بك.

ما هو حجم المنتدى الذي نتحدث عنه هنا؟ قد يكون خطة بريد إلكتروني مجانية كافية.

لقد قمت بتكوين إعدادات SMTP باستخدام Brevo واستخدمت المنفذ 587، وما زلت أتلقى نفس الخطأ. يرجى المساعدة بلطف، لست متأكدًا من أين أخطأت.

حسناً… ماذا عن تغيير المنفذ إلى 2525؟

إعجاب واحد (1)

هل تمكنت من جعل هذا يعمل؟