Configurar copias de seguridad automáticas para Discourse

:bookmark: Esta guía explica cómo configurar las copias de seguridad automáticas para Discourse, incluidas las opciones de almacenamiento en servidores locales y almacenamiento compatible con S3.

Aprende a configurar las copias de seguridad automáticas para tu plataforma Discourse.

Esta guía cubre la configuración de copias de seguridad automáticas, su almacenamiento en servidores locales o almacenamiento compatible con S3, y la gestión de opciones de retención de almacenamiento como Amazon Glacier.

Configuración de copias de seguridad automáticas

  1. Navega a la configuración de /admin.
  2. Selecciona la sección Backup (Copia de seguridad).
  3. Establece backup_frequency al intervalo deseado en días. El valor predeterminado es 7 (semanal). Establécelo en 1 para copias de seguridad diarias, o 0 para desactivar las copias de seguridad automáticas. El máximo es 30.

backup_frequencybackup_frequency100%75%50%

Configuración adicional de copias de seguridad

  • backup_time_of_day — la hora del día (UTC) en que se ejecutan las copias de seguridad. Predeterminado: 3:30.
  • backup_with_uploads — incluye las cargas (uploads) en las copias de seguridad programadas. Predeterminado: habilitado. Deshabilitar esto solo hará una copia de seguridad de la base de datos.
  • maximum_backups — el número máximo de copias de seguridad a conservar. Las copias de seguridad más antiguas se eliminan automáticamente. Predeterminado: 5.
  • remove_older_backups — elimina las copias de seguridad más antiguas que el número de días especificado. Deja en blanco para deshabilitar.

Almacenar copias de seguridad en el servidor local

Por defecto, las copias de seguridad se almacenan en tu servidor local. Para instancias autohospedadas, accédelas en /var/discourse/shared/standalone/backups/default.

Almacenar copias de seguridad en almacenamiento compatible con S3

Usando el panel de administración

  1. Crea un bucket S3.
  2. Establece s3_backup_bucket en el panel de administración.
  1. Configura s3_access_key_id, s3_secret_access_key y s3_region.
  2. Establece backup_location a “S3”.

image

:warning: ADVERTENCIA

Almacenar copias de seguridad y cargas (uploads) regulares en el mismo bucket y carpeta ya no es compatible y no funcionará.

La ruta s3_backup_bucket debe usarse solo para copias de seguridad. Si necesitas usar un bucket que contenga otros archivos, asegúrate de proporcionar un prefijo al configurar la opción s3_backup_bucket (ejemplo: my-awesome-bucket/backups) y asegúrate de que los archivos con ese prefijo sean privados.

A partir de ahora, todas las copias de seguridad se subirán a S3 y no se almacenarán localmente. El almacenamiento local solo se utilizará para archivos temporales durante las copias de seguridad y restauraciones.

Ve a la pestaña Backups en el panel de administración para explorar las copias de seguridad; puedes descargarlas en cualquier momento para realizar una copia de seguridad manual fuera del sitio.

Usando variables de entorno en app.yml

También puedes configurar las copias de seguridad de S3 utilizando variables de entorno en app.yml. Para más información, consulta Configurar un proveedor de almacenamiento de objetos compatible con S3 para las cargas (uploads)

Ten en cuenta que el artículo anterior cubre la configuración de S3 en app.yml tanto para copias de seguridad como para cargas de archivos/imágenes. Si solo deseas utilizar S3 para copias de seguridad (y no para cargas de archivos/imágenes), puedes omitir los siguientes parámetros de tu configuración de app.yml:

  • DISCOURSE_USE_S3
  • DISCOURSE_S3_CDN_URL
  • DISCOURSE_S3_BUCKET

Tampoco necesitas configurar el paso after_assets_precompile en este caso, ni configurar una CDN.

Asegúrate de incluir todos los demás parámetros que son necesarios para tu proveedor de almacenamiento, como se menciona en el artículo. Aquí hay un ejemplo de configuración que solo activa S3 para copias de seguridad (para 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

Archivado a almacenamiento con menor coste

Ten en cuenta que en AWS S3, también puedes habilitar una regla del ciclo de vida para mover automáticamente a un bucket Glacier para mantener bajos los costes de tus copias de seguridad de S3. Otros proveedores de almacenamiento a menudo tienen una oferta similar.

59 Me gusta

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 Me gusta

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 Me gusta

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 me gusta

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 Me gusta

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 me gusta

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 Me gusta

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 me gusta

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 me gusta

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 Me gusta

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

1 me gusta

I had the very same problem!

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

3 Me gusta

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 me gusta

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 me gusta

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

3 Me gusta