Backing up and moving Weblate¶
Automated backup using BorgBackup¶
バージョン 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 on the Backups tab.
バージョン 4.4.1 で変更: Both PostgreSQL and MySQL/MariaDB databases are included in the automated backups.
The backups using Borg are incremental and Weblate is configured to keep following backups:
14 daily backups
8 weekly backups
6 monthly backups

Borg encryption key¶
BorgBackup creates encrypted backups and without a passphrase you will not be able to restore the backup. The passphrase is generated when adding new backup service and you should copy it and keep it in a secure place.
In case you are using Weblate provisioned backup storage, please backup your private SSH key as well — it is used to access your backups.
参考
Weblate provisioned backup storage¶
The easiest approach to backup your Weblate instance is to purchase backup service at weblate.org. The process of activating can be performed in few steps:
Purchase backup service on https://weblate.org/support/#backup.
Enter obtained key in the management interface, see Integrating support.
Weblate will connect to the cloud service and obtain access information for the backups.
Turn on the new backup configuration on the Backups tab.
Backup Borg credentials in order to be able to restore the backups, see Borg encryption key.
ヒント
The manual step of turning on is there for your safety. Without your consent no data is sent to the backup repository obtained through the registration process.
Using custom backup storage¶
You can also use your own storage for the backups. SSH can be used to store backups on the remote destination, the target server needs to have BorgBackup installed.
参考
General in the Borg documentation
Local filesystem¶
It is recommended to specify absolute path for the local backup, for example /path/to/backup. The directory has to be writable by user running Weblate (see ファイル システムのアクセス権). In case it doesn't exist, Weblate will attempt to create it, but it needs permissions to do so.
ヒント
When running Weblate in Docker, please make sure that the backup location is exposed as a volume from the Weblate container. Otherwise the backups would be discarded by Docker on container restart.
One option is to place backups in existing volume. For example choose
/app/data/borgbackup
. This is existing volume in the container.
You can also add new container for the backups in the Docker compose file
and use for example /borgbackup
:
services:
weblate:
volumes:
- /home/weblate/data:/app/data
- /home/weblate/borgbackup:/borgbackup
The directory where backups will be stored have to be owned by UID 1000, otherwise Weblate will not be able to write the backups there.
リモート バックアップ¶
Remote backups using SSH are supported. The SSH server needs to have BorgBackup installed. Weblate connects to the server using SSH key, please make sure the Weblate SSH key is accepted by the server (see Weblate SSH キー).
ヒント
Weblate provisioned backup storage provides you automated remote backups.
Restoring from BorgBackup¶
Restore access to your backup repository and prepare your backup passphrase.
List backup existing on the server using
borg list REPOSITORY
.Restore the desired backup to current directory using
borg extract REPOSITORY::ARCHIVE
.Restore the database from the SQL dump placed in the
backup
directory in the Weblate data dir (see Dumped data for backups).Copy Weblate configuration (
backups/settings.py
, see Dumped data for backups) to the correct location, see 設定の調整.Copy the whole restored data dir to location configured by
DATA_DIR
.
The Borg session might look like:
$ 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:
Manual backup¶
Depending on what you want to save, back up the type data Weblate stores in each respective place.
ヒント
In case you are doing manual backups, you might want to silent Weblate
warning about 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")
Database¶
The actual storage location depends on your database setup.
The database is the most important storage. Set up regular backups of your database, without it all your translation setup will be gone.
Native database backup¶
The recommended approach is to do dump of the database using database native tools such as pg_dump or mysqldump. It usually performs better than Django backup and restores complete tables with all data.
You can restore this backup in newer Weblate release, it will perform any
necessary migrations when running in migrate
. Please consult
Upgrading Weblate on more detailed information how to perform upgrade between
versions.
Django database backup¶
Alternatively you can backup database using Django's dumpdata
command. That way the backup is database agnostic and can be used in case you
want to change database backend.
Prior to restoring you need to be running exactly same Weblate version as was
used when doing backups. 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
.
Once this is done, some entries will be already 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 management shell (see Invoking management commands):
weblate shell
>>> from weblate.auth.models import User
>>> User.objects.get(username='anonymous').delete()
ファイル¶
If you have enough backup space, simply backup the whole DATA_DIR
. This
is safe bet even if it includes some files you don't want.
The following sections describe in detail what you should back up and what you
can skip.
Dumped data for backups¶
Stored in 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 Background tasks using Celery). Currently, this includes:
Weblate settings as
settings.py
(there is also expanded version insettings-expanded.py
).PostgreSQL database backup as
database.sql
.
The database backups are by default saved as plain text, but they can also be compressed
or entirely skipped by using DATABASE_BACKUP
.
Version control repositories¶
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 and you do not have to backup the repositories on the Weblate side. They can be cloned again from the upstream locations with no data loss.
SSH and GPG keys¶
Stored in DATA_DIR
/ssh
and DATA_DIR
/home
.
If you are using SSH or GPG keys generated by Weblate, you should back up these locations, otherwise you will lose the private keys and you will have to regenerate new ones.
User uploaded files¶
Stored in DATA_DIR
/media
.
You should back up user uploaded files (e.g. Visual context for strings).
Celery tasks¶
The Celery tasks queue might contain some info, but is usually not needed for a backup. At most you will lose updates that have not yet been processed to translation memory. It is recommended to perform the fulltext or repository updates upon restoring anyhow, so there is no problem in losing these.
Command line for manual backup¶
Using a cron job, you can set up a bash command to be executed on a daily basis, for instance:
$ 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 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
You can adjust the list of folders and files to your needs. For instance, to avoid saving the translation memory (in backups folder), you could use:
$ 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
Restoring manual backup¶
Restore all data you have backed up.
Update all repositories using
updategit
.weblate updategit --all
Moving a Weblate installation¶
Relocate your installation to a different system by following the backup and restore instructions above.