Respaldar y trasladar Weblate

Copia de respaldo automatizada utilizando BorgBAckup

Nuevo en la versión 3.9.

Weblate has built-in support for creating service backups using BorgBackup. Borg creates space-effective encrypted backups which can be safely stored in the cloud. The backups can be controlled in the management interface from the Backups tab.

Distinto en la versión 4.4.1: Se incluyen las bases de datos de tanto PostgreSQL como MySQL/MariaDB en las copias de respaldo automatizadas.

The backups using Borg are incremental and Weblate is configured to keep following backups:

  • Copias de respaldo diarias para 14 días

  • Copias de respaldo semanales para 8 semanas

  • Copias de respaldo mensuales para 6 meses

../_images/backups.png

Clave de cifrado de Borg

BorgBackup creates encrypted backups and you wouldn’t be able to restore them without the passphrase. The passphrase is generated when adding a new backup service and you should copy it and keep it in a secure place.

If you are using Weblate provisioned backup storage, please backup your private SSH key too, as it’s used to access your backups.

Ver también

borg init

Weblate provisioned backup storage

The easiest way of backing up your Weblate instance is purchasing the backup service at weblate.org. This is how you get it running:

  1. Purchase the Backup service on https://weblate.org/support/#backup.

  2. Enter the obtained key in the management interface, see Integrating support.

  3. Weblate connects to the cloud service and obtains access info for the backups.

  4. Turn on the new backup configuration from the Backups tab.

  5. Backup your Borg credentials to be able to restore the backups, see Clave de cifrado de Borg.

Consejo

The manual step of turning everything on is there for your safety. Without your consent no data is sent to the backup repository obtained through the registration process.

Utilizar un almacenamiento personalizado para los respaldos

You can also use your own storage for the backups. SSH can be used to store backups in the remote destination, the target server needs to have BorgBackup installed.

Ver también

General en la documentación de Borg

Sistema de archivos local

Es recomendable especificar una ruta absoluta para la copia de respaldo local, como /ruta/al/respaldo. El directorio debe ser escribible por la cuenta de usuario que ejecute Weblate (vea Permisos del sistema de archivos). Si no existe la ubicación, Weblate intentará crearla, pero necesita permiso para hacerlo.

Consejo

Siempre que se ejecute Weblate en Docker, hay que asegurarse de que la ubicación de las copias de respaldo esté expuesta como volumen desde el contenedor de Weblate. De otro modo, Docker descartará las copias de respaldo al momento de reiniciar el contenedor.

One option is to place backups into an existing volume, for example /app/data/borgbackup. This is an existing volume in the container.

You can also add a new container for the backups in the Docker Compose file for example by using /borgbackup:

services:
  weblate:
    volumes:
      - /home/weblate/data:/app/data
      - /home/weblate/borgbackup:/borgbackup

El propietario del directorio donde se habrán de almacenar las copias de respaldo debe ser el UID 1000, o Weblate no podrá guardar las copias de respaldo allí.

Copias de respaldo remotas

In order to create the remote backups, you will have to install BorgBackup onto another server that’s accessible via SSH. Make sure that it accepts the Weblate’s client SSH key, i.e. the one it uses to connect to other servers.

Consejo

Weblate provisioned backup storage le ofrece copias de respaldo automatizadas.

Ver también

Clave SSH de Weblate

Restaurar a partir de BorgBackup

  1. Restore access to your backup repository and prepare your backup passphrase.

  2. List all the backups on the server using borg list REPOSITORY.

  3. Restore the desired backup to the current directory using borg extract REPOSITORY::ARCHIVE.

  4. Restore the database from the SQL dump placed in the backup directory in the Weblate data dir (see Datos volcados para las copias de respaldo).

  5. Copy the Weblate configuration (backups/settings.py, see Datos volcados para las copias de respaldo) to the correct location, see Adjusting configuration.

  6. Copy the whole restored data dir to the location configured by DATA_DIR.

The Borg session might look like this:

$ borg list /tmp/xxx
Enter passphrase for key /tmp/xxx:
2019-09-26T14:56:08                  Thu, 2019-09-26 14:56:08 [de0e0f13643635d5090e9896bdaceb92a023050749ad3f3350e788f1a65576a5]
$ borg extract /tmp/xxx::2019-09-26T14:56:08
Enter passphrase for key /tmp/xxx:

Ver también

borg list, borg extract

Copia de respaldo manual

En función de lo que desee guardar, respalde los tipos de datos que Weblate almacena en cada sitio respectivo.

Consejo

If you are doing the manual backups, you might want to silence Weblate’s warning about a lack of backups by adding weblate.I028 to SILENCED_SYSTEM_CHECKS in settings.py or WEBLATE_SILENCED_SYSTEM_CHECKS for Docker.

SILENCED_SYSTEM_CHECKS.append("weblate.I028")

Base de datos

The actual storage location depends on your database setup.

Consejo

El almacenamiento más importante es el de la base de datos. Configure copias de respaldo periódicas de la base de datos. Sin esta, todas las traducciones desaparecerán.

Native database backup

The recommended approach is to save a dump of the database using database-native tools such as pg_dump or mysqldump. It usually performs better than Django backup, and it restores complete tables with all their data.

You can restore this backup in a newer Weblate release, it will perform all the necessary migrations when running in migrate. Please consult Actualizar Weblate on more detailed info on how to upgrade between versions.

Django database backup

Alternatively, you can back up your database using Django’s dumpdata command. That way the backup is database agnostic and can be used in case you want to change the database backend.

Prior to restoring the database you need to be running exactly the same Weblate version the backup was made on. This is necessary as the database structure does change between releases and you would end up corrupting the data in some way. After installing the same version, run all database migrations using migrate.

Afterwards some entries will already be created in the database and you will have them in the database backup as well. The recommended approach is to delete such entries manually using the management shell (see Invocar órdenes de gestión):

weblate shell
>>> from weblate.auth.models import User
>>> User.objects.get(username='anonymous').delete()

Archivos

If you have enough backup space, simply back up the whole DATA_DIR. This is a safe bet even if it includes some files you don’t want. The following sections describe what you should back up and what you can skip in detail.

Datos volcados para las copias de respaldo

Almacenados en DATA_DIR /backups.

Weblate dumps various data here, and you can include these files for more complete backups. The files are updated daily (requires a running Celery beats server, see Tareas en segundo plano con Celery). Currently, this includes:

  • Weblate settings as settings.py (there is also expanded version in settings-expanded.py).

  • PostgreSQL database backup as database.sql.

The database backups are saved as plain text by default, but they can also be compressed or entirely skipped using DATABASE_BACKUP.

Repositorios de control de versiones

Stored in DATA_DIR /vcs.

The version control repositories contain a copy of your upstream repositories with Weblate changes. If you have Push on commit enabled for all your translation components, all Weblate changes are included upstream. No need to back up the repositories on the Weblate side as they can be cloned again from the upstream location(s) with no data loss.

Claves SSH y GPG

Stored in DATA_DIR /ssh and DATA_DIR /home.

Si utiliza las claves SSH o GPG que Weblate genera, debe realizar copias de respaldo de esas ubicaciones. De lo contrario, podría perder las claves privadas y habrá de generar nuevas.

Archivos cargados por los usuarios

Stored in DATA_DIR /media.

Debe crear copias de respaldo de todos los archivos que cargan los usuarios (p. ej., Contexto visual para cadenas).

Tareas de Celery

The Celery task queue might contain some info, but is usually not needed for a backup. At most you will lose updates not yet been processed to translation memory. It is recommended to perform the fulltext or repository update upon restoration anyhow, so there is no problem in losing these.

Órdenes de interfaz de texto para efectuar copias de respaldo manualmente

Con la ayuda de una tarea de cron es posible montar una orden de Bash que se ejecute diariamente. Por ejemplo:

$ XZ_OPT="-9" tar -Jcf ~/backup/weblate-backup-$(date -u +%Y-%m-%d_%H%M%S).xz backups vcs ssh home media fonts secret

The string between the quotes after XZ_OPT allows you to choose your xz options, for instance the amount of memory used for compression; see https://linux.die.net/man/1/xz

Puede ajustar la lista de carpetas y de archivos para adecuarla a sus necesidades. Para evitar guardar la memoria de traducción (en la carpeta de las copias de respaldo), puede utilizar:

$ XZ_OPT="-9" tar -Jcf ~/backup/weblate-backup-$(date -u +%Y-%m-%d_%H%M%S).xz backups/database.sql backups/settings.py vcs ssh home media fonts secret

Restaurar una copia de respaldo manual

  1. Restaure todos los datos de los que ha hecho copia de respaldo.

  2. Actualice todos los repositorios mediante updategit.

    weblate updategit --all
    

Trasladar una instalación de Weblate

Para mudar su instalación a un sistema diferente, siga las instrucciones de respaldo y restauración anteriores.