إعداد النسخ الاحتياطي التلقائي لـ Discourse

:bookmark: يشرح هذا الدليل كيفية تكوين النسخ الاحتياطي التلقائي لـ Discourse، بما في ذلك خيارات التخزين على الخوادم المحلية والتخزين المتوافق مع S3.

تعلم كيفية إعداد النسخ الاحتياطي التلقائي لمنصة Discourse الخاصة بك.

يغطي هذا الدليل تكوين النسخ الاحتياطي التلقائي، وتخزينها على الخوادم المحلية أو التخزين المتوافق مع S3، وإدارة خيارات الاحتفاظ بالتخزين مثل Amazon Glacier.

تكوين النسخ الاحتياطي التلقائي

  1. انتقل إلى إعدادات /admin.
  2. حدد قسم Backup (النسخ الاحتياطي).
  3. اضبط backup_frequency على الفاصل الزمني المطلوب بالأيام. القيمة الافتراضية هي 7 (أسبوعيًا). اضبطها على 1 للنسخ الاحتياطي اليومي، أو 0 لتعطيل النسخ الاحتياطي التلقائي. الحد الأقصى هو 30.

backup_frequencybackup_frequency100%75%50%

إعدادات النسخ الاحتياطي الإضافية

  • backup_time_of_day — وقت اليوم (بالتوقيت العالمي المنسق UTC) الذي تعمل فيه النسخ الاحتياطية. الافتراضي: 3:30.
  • backup_with_uploads — تضمين الملفات المحملة في النسخ الاحتياطية المجدولة. الافتراضي: ممكّن. سيؤدي تعطيل هذا إلى نسخ قاعدة البيانات احتياطيًا فقط.
  • maximum_backups — الحد الأقصى لعدد النسخ الاحتياطية التي سيتم الاحتفاظ بها. يتم حذف النسخ الاحتياطية الأقدم تلقائيًا. الافتراضي: 5.
  • remove_older_backups — إزالة النسخ الاحتياطية الأقدم من العدد المحدد من الأيام. اتركها فارغة لتعطيل هذه الميزة.

تخزين النسخ الاحتياطية على الخادم المحلي

بشكل افتراضي، يتم تخزين النسخ الاحتياطية على الخادم المحلي الخاص بك. بالنسبة للتثبيتات المستضافة ذاتيًا، يمكنك الوصول إليها على /var/discourse/shared/standalone/backups/default.

تخزين النسخ الاحتياطية على تخزين متوافق مع S3

استخدام لوحة الإدارة

  1. أنشئ حاوية S3 (S3 bucket).
  2. اضبط s3_backup_bucket في لوحة الإدارة.
  1. قم بتكوين s3_access_key_id و s3_secret_access_key و s3_region.
  2. اضبط backup_location على “S3”.

image

:warning: تحذير

لم يعد تخزين النسخ الاحتياطية وعمليات التحميل العادية في نفس الحاوية و المجلد مدعومًا و لن يعمل.

يجب استخدام مسار s3_backup_bucket للنسخ الاحتياطية فقط. إذا كنت بحاجة إلى استخدام حاوية تحتوي على ملفات أخرى، فتأكد من توفير بادئة عند تكوين إعداد s3_backup_bucket (مثال: my-awesome-bucket/backups) وتأكد من أن الملفات التي تحمل هذه البادئة خاصة.

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

انتقل إلى علامة التبويب Backups (النسخ الاحتياطية) في لوحة معلومات المسؤول لتصفح النسخ الاحتياطية – يمكنك تنزيلها في أي وقت لإجراء نسخة احتياطية يدوية خارج الموقع.

استخدام متغيرات البيئة في app.yml

يمكنك أيضًا تكوين نسخ S3 الاحتياطية باستخدام متغيرات البيئة في app.yml. لمزيد من المعلومات، راجع تكوين موفر تخزين كائن متوافق مع S3 لعمليات التحميل

لاحظ أن المقالة المذكورة أعلاه التي تغطي app.yml تغطي إعداد S3 للنسخ الاحتياطي ولـ تحميل الملفات/الصور. إذا كنت تريد فقط استخدام S3 للنسخ الاحتياطي (وليس لتحميل الملفات/الصور)، فيمكنك إغفال المعلمات التالية من تكوين app.yml الخاص بك:

  • DISCOURSE_USE_S3
  • DISCOURSE_S3_CDN_URL
  • DISCOURSE_S3_BUCKET

لست بحاجة أيضًا إلى تكوين خطوة after_assets_precompile في هذه الحالة، ولا تكوين شبكة توصيل محتوى (CDN).

تأكد من تضمين جميع المعلمات الأخرى المطلوبة لموفر التخزين الخاص بك، كما هو مذكور في المقالة. فيما يلي مثال واحد للتكوين ينشط S3 للنسخ الاحتياطي فقط (لـ Scaleway S3):

DISCOURSE_S3_REGION: nl-ams
DISCOURSE_S3_ENDPOINT: https://s3.nl-ams.scw.cloud
DISCOURSE_S3_ACCESS_KEY_ID: my_access_key
DISCOURSE_S3_SECRET_ACCESS_KEY: my_secret_access_key
DISCOURSE_S3_BACKUP_BUCKET: my_bucket/my_folder
DISCOURSE_BACKUP_LOCATION: s3

الأرشفة إلى تخزين بتكلفة أقل

لاحظ أنه على AWS S3، يمكنك أيضًا تمكين قاعدة دورة حياة النقل التلقائي إلى حاوية Glacier للحفاظ على تكاليف النسخ الاحتياطي لـ S3 منخفضة. غالبًا ما يكون لموفري التخزين الآخرين عرض مماثل.

59 إعجابًا

You are able to Archive Backups from your S3 Bucket to Glacier.
It is cheaper, but an Restore attemps more Time.

This Site will Help you to reduce Backup costs.:

11 إعجابًا

Setting this up can be rather confusing. Here’s a simple guide to help you out.

  • Log into your Discourse admin panel
  • Configure daily backups
  • Set maximum backups to 7
  • Log into your Amazon Web Services account
  • Go in the S3 Dashboard
  • Open the bucket containing the backups
  • Click on the properties tab
  • Activate versioning
  • Open the Lifecycle menu
  • Add a rule for the whole bucket
  • Set current version to expire after 15 days
  • Set previous version to
  • Archive to Glacier after 1 days
  • expire after 91 days
  • Save and logout

How it works

Versioning will keep backups automaticly deleted by Discourse. One day after beeing deleted it will be moved to the Glacier storage. After 91 days it will be delete from the Glacier storage.

Warning

Amazon charge you for item stored in Glacier for 90 days even if you delete them before. Make sure your Glacier Lyfecicle keep your file at least 90 days.

11 إعجابًا

I may have missed this, but how to I make sure a bucket for backups is private the proper way? Setting up file and image uploads to S3 doesn’t seem to be described here.

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

Looks like there is no such option anymore.

UPD: ah, now it’s split into 2 steps of this wizard.

So I guess it should be like this:

إعجابَين (2)

Does S3 backup functionality play nice without IAM access key and secret if using AWS roles assigned to the instance and s3 use iam profile is enabled in the settings menu?

Edit: The answer is YES! Just ensure you have region set appropriately.

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

I had this problem too, which was resolved by adding a couple of lines to the policy document:

"Resource": [
        "arn:aws:s3:::your-uploads-bucket",
        "arn:aws:s3:::your-uploads-bucket/*",
        "arn:aws:s3:::your-backups-bucket",
        "arn:aws:s3:::your-backups-bucket/*"
      ]

Should this be added to the OP (which isn’t a wiki)? Or perhaps in the OP of Set up file and image uploads to S3?

إعجابَين (2)

Is there a good reason not to make daily backups aren’t the default?

Fixes needed for OP

Add something about moving S3 backups to Glacier?
Delete the S3 stuff and link to Configure an S3 compatible object storage provider for uploads

It’d be overkill and expensive. Same reason we don’t recommend changing the oil in your car every 500 miles?

You back up your servers once a week?

I think your 500 mile oil change analogy would be a good answer for “why not keep 30 backups?”, but it doesn’t make sense to me here.

Do you not think that if you’re going to have 5 backups most people would rather have backups every day so that if they do have to revert to a backup they’ve lost no more than a day? The only time I remember an older backup being useful is when images fell out of tombstone.

If they have so little disk space that they can’t hold 5 backups, it would seem better to learn that in 5 days when they still have some memory of what they did than wait 4-5 weeks.

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

Yes, that is correct, for my self hosted servers.

If you prefer different settings, feel free to edit them from the defaults. What’s stopping you from doing so?

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

Well, I’ll be!

I’m cleaning up topics like this one. If the defaults were changed, it wouldn’t be needed!

I’m convinced that the defaults won’t be changed, so I’ll move ahead. :wink

إعجابَين (2)

Once a week is a good starting point and a solid default.

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

I had the very same problem!

i suggest to add a note regarding this on the initial post too!

3 إعجابات

Would be nice if this could be used to upload to a different S3 compatible provider, such as running MinIO.

If you want to use minio, see Using Object Storage for Uploads (S3 & Clones). If you want different services for backups and assets then you’re out of luck (though there are ways to set up triggers to copy from one bucket 8 another)

No, just want for backups, so they get automatically pushed to a different machine on my network.

Then the guide I linked is what you’re looking for.

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

Is it possible to be more frequent than once per day? I’d rather not make assumptions and set backup freqeuncy to a float

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

If you want more frequent backups you’ll need to do them externally.

3 إعجابات