Discourse automatische Backups konfigurieren

:bookmark: Diese Anleitung erklärt, wie Sie automatische Backups für Discourse konfigurieren, einschließlich Speicheroptionen auf lokalen Servern und S3-kompatiblem Speicher.

Erfahren Sie, wie Sie automatische Backups für Ihre Discourse-Plattform einrichten.

Diese Anleitung behandelt die Konfiguration automatischer Backups, deren Speicherung auf lokalen Servern oder S3-kompatiblem Speicher und die Verwaltung von Aufbewahrungsoptionen wie Amazon Glacier.

Automatische Backups konfigurieren

  1. Navigieren Sie zu den /admin-Einstellungen.
  2. Wählen Sie den Abschnitt Backup (Sicherung).
  3. Legen Sie backup_frequency auf das gewünschte Intervall in Tagen fest. Der Standardwert ist 7 (wöchentlich). Setzen Sie ihn auf 1 für tägliche Backups oder auf 0, um automatische Backups zu deaktivieren. Das Maximum ist 30.

backup_frequencybackup_frequency100%75%50%

Zusätzliche Backup-Einstellungen

  • backup_time_of_day — Die Tageszeit (UTC), zu der Backups ausgeführt werden. Standard: 3:30.
  • backup_with_uploads — Schließt Uploads in geplante Backups ein. Standard: aktiviert. Wenn dies deaktiviert wird, wird nur die Datenbank gesichert.
  • maximum_backups — Die maximale Anzahl der aufzubewahrenden Backups. Ältere Backups werden automatisch gelöscht. Standard: 5.
  • remove_older_backups — Entfernt Backups, die älter als die angegebene Anzahl von Tagen sind. Leer lassen, um dies zu deaktivieren.

Backups auf dem lokalen Server speichern

Standardmäßig werden Backups auf Ihrem lokalen Server gespeichert. Für selbst gehostete Instanzen finden Sie diese unter /var/discourse/shared/standalone/backups/default.

Backups auf S3-kompatiblem Speicher speichern

Verwendung des Admin-Panels

  1. Erstellen Sie einen S3-Bucket.
  2. Legen Sie s3_backup_bucket im Admin-Panel fest.
  1. Konfigurieren Sie s3_access_key_id, s3_secret_access_key und s3_region.
  2. Setzen Sie backup_location auf „S3“.

image

:warning: WARNUNG

Das Speichern von Backups und regulären Uploads im selben Bucket und Ordner wird nicht mehr unterstützt und wird nicht funktionieren.

Der Pfad s3_backup_bucket sollte nur für Backups verwendet werden. Wenn Sie einen Bucket verwenden möchten, der andere Dateien enthält, stellen Sie sicher, dass Sie beim Konfigurieren der Einstellung s3_backup_bucket ein Präfix angeben (Beispiel: my-awesome-bucket/backups) und stellen Sie sicher, dass Dateien mit diesem Präfix privat sind.

Von nun an werden alle Backups zu S3 hochgeladen und nicht mehr lokal gespeichert. Der lokale Speicher wird nur für temporäre Dateien während Backups und Wiederherstellungen verwendet.

Gehen Sie zum Tab Backups im Admin-Dashboard, um die Backups zu durchsuchen – Sie können sie jederzeit herunterladen, um ein manuelles Offsite-Backup durchzuführen.

Verwendung von Umgebungsvariablen in app.yml

Sie können S3-Backups auch mithilfe von Umgebungsvariablen in app.yml konfigurieren. Weitere Informationen finden Sie unter Konfigurieren eines S3-kompatiblen Objektspeichers für Uploads.

Beachten Sie, dass der obige Artikel die S3-Einrichtung für Backups und für Datei-/Bild-Uploads in app.yml behandelt. Wenn Sie S3 nur für Backups (und nicht für Uploads von Dateien/Bildern) verwenden möchten, können Sie die folgenden Parameter aus Ihrer app.yml-Konfiguration weglassen:

  • DISCOURSE_USE_S3
  • DISCOURSE_S3_CDN_URL
  • DISCOURSE_S3_BUCKET

In diesem Fall müssen Sie auch den Schritt after_assets_precompile nicht konfigurieren, ebenso wenig wie ein CDN.

Stellen Sie sicher, dass Sie alle anderen erforderlichen Parameter für Ihren Speicheranbieter einschließen, wie im Artikel erwähnt. Hier ist ein Beispiel für eine Konfiguration, die S3 nur für Backups aktiviert (für 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

Archivierung in kostengünstigerem Speicher

Beachten Sie, dass Sie bei AWS S3 auch eine automatische Verschiebung in einen Glacier-Bucket mithilfe einer Lebenszyklusregel aktivieren können, um Ihre S3-Backupkosten niedrig zu halten. Andere Speicheranbieter haben oft ein ähnliches Angebot.

59 „Gefällt mir“

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 „Gefällt mir“

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 „Gefällt mir“

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 „Gefällt mir“

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 „Gefällt mir“

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 „Gefällt mir“

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 „Gefällt mir“

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 „Gefällt mir“

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 „Gefällt mir“

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 „Gefällt mir“

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

1 „Gefällt mir“

I had the very same problem!

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

3 „Gefällt mir“

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 „Gefällt mir“

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 „Gefällt mir“

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

3 „Gefällt mir“