نسخ احتياطي للنقاش من سطر الأوامر

:bookmark: This guide covers how to back up and restore your Discourse site using command line tools, specifically designed for self-hosted environments.

:person_raising_hand: Required user level: Administrator

:information_source: You can use the below placeholders to automatically fill out the command line prompts in this guide:

Backing up

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

  1. Enter the container:
./launcher enter app
  1. Run the backup:
discourse backup
exit

This will print out the final filename of your backup. Download the backup and container configuration (if needed) to your local machine:

scp =USER=@=HOST=:/var/discourse/shared/standalone/backups/default/=FILENAME= .
scp =USER=@=HOST=:/var/discourse/containers/app.yml .

Restoring

To restore a Discourse backup, follow these steps:

  1. Install a Discourse site on the server you are restoring to.

If you’re testing this procedure multiple times, you can wipe the data on your test server.

Wipe Discourse data (optional)
./launcher stop app
./launcher destroy app
rm -r /var/discourse/shared/standalone/
mkdir -p /var/discourse/shared/standalone/backups/default/

  1. Upload the backup file:
scp =FILENAME= =USER=@=HOST=:/var/discourse/shared/standalone/backups/default/
  1. Enter the container and start the restore:
./launcher enter app
discourse enable_restore
discourse restore =FILENAME=

If you happen to forget what the filename was, run the “discourse restore” command by itself to get a list of available backup files.

:information_source: For a two-container setup, use ./launcher enter web_only and replace standalone with web-only in the path to backups.

For additional information about restoring Discourse backups, see Restore a backup from the command line.

Last edited by @SaraDev 2024-08-23T20:50:17Z

Check documentPerform check on document:
38 إعجابًا

أين يجب أن أقوم بتشغيل هذا الأمر؟ في طرفية الخادم السحابي الخاص بي أم جهازي المحلي؟
على الرغم من أن كلاهما يعطيني خطأ “رفض الإذن”

على جهازك المحلي.

هل تستخدم مفتاح SSH للاتصال؟ الخطأ متعلق بذلك.

يجب أن يكون الأمر بعد ذلك:

scp -i /path_to_your_key/your_key.pem root@147.43.15.199:/var/discourse/shared/standalone/backups/default/discourse-2024-12-25-033740-v20241211222608.tar.gz .

لدي سيناريو أرغب فيه في ترحيل تثبيت Discourse إلى خادم جديد تمامًا.
كانت خطتي:

  1. إنشاء تثبيت Discourse جديد فارغ
  2. عمل نسخة احتياطية من Discourse القديم، ونسخها احتياطيًا إلى الخادم الجديد واستعادتها
  3. نسخ كل شيء من S3 (صور، إلخ) إلى S3 جديد في حساب مختلف

تنجح عملية الاستعادة جيدًا حتى تبدأ في البحث عن S3 ثم تفشل لعدم وجود وصول. أعتقد أنها تحاول الوصول إلى نفس اسم حاوية S3 على Discourse القديم، ولكن هذه الحاوية غير موجودة في الحاوية الجديدة ولا يمكنني إنشاؤها.

هل هناك حل موصى به؟

اعتقدت أنه يمكنني محاولة تغيير اسم حاوية S3 على Discourse القديم (قبل إجراء النسخ الاحتياطي) ثم عند الاستعادة، سيتوقع وجود حاوية S3 الجديدة. لكنني أخشى مما سيحدث لـ Discourse القديم إذا قمت بتبديله إلى حاوية غير موجودة.

هناك إعداد مخفي سيقوم بتنزيل ملفات s3 ووضعها في النسخة الاحتياطية.

تحتاج إلى تكوين s3 في ملف yml كما هو موضح في تكوين موفر تخزين كائنات متوافق مع S3 للتحميلات

بعد ذلك، عند استعادة النسخة الاحتياطية، سيتم دفع التحميلات إلى الدلو الجديد.

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

هل اكتشفت هذا الأمر؟

تحتاج إلى تكوين s3 في متغيرات البيئة كما هو موضح في تكوين موفر تخزين كائنات متوافق مع S3 لعمليات التحميل

هذا صحيح بشكل خاص إذا كانت إعدادات s3 مختلفة على الخادم الجديد. يمكن أن يتسبب وضع قيم s3 في قاعدة البيانات في حدوث الكثير من المشاكل.

ولكن هناك مفتاح لأمر الاستعادة يجعله يتوقف مؤقتًا بين الأجزاء المختلفة. يمكن أن يساعد ذلك.