Backup and disaster recovery¶
Introduction¶
While you might never use them, your backup plan (and the corresponding disaster recovery steps) are possibly your most important procedure.
You should:
- Write it up fully
- Test it from beginning to end, simulating an actual disaster
- Run backups on a regular basis, ideally automatically
This page explains in detail how to properly backup an on-premise Wire installation, and how to recover from your backup if you ever need to.
Note that you should not trust this page (or your execution of it) to allow for a proper backup and restore, therefore, you should immediately (before it becomes critical to do so) back up your Wire installation and attempt (as a test) to restore it. This will ensure that you can in fact backup and restore Wire, and will catch any problem in the process before any problem becomes damaging to you.
Backing up¶
By nature, a significant part of a Wire installation is ephemeral, and not meant to be stored long-term or recovered: in case of trouble, those parts can just be started fresh with minimal impact on user experience.
The exceptions to this rule, are what you want to back up. In particular:
- Your “wire-server” installation folder (used during the installation procedure)
- Your Cassandra database
- Your Minio data
If you save these, you can then whenever needed, create a fresh installation of Wire, re-import/re-install them on top of it, and get back to a working state.
Here is how to back up each:
Backing up Wire-server¶
To backup the wire-server folder, we simply use ssh to read it from the server in which it is installed:
Where :
user
is the user you used to install Wire on this server, typicallywire
orroot
my-wire-server.your-domain.com
is the domain name or IP address for the server with your Wire install/path/to/my/folder/for/wire-server/
is the (absolute) path, on the server, where your wire-server folder is locatedwire-server
is the name of the folder for your wire-server install, typically (as per instructions) simplywire-server
wire-server-backup.tar.gz
is the name of the file in which your wire-server folder will be stored
Once the command is done executing, make sure the file exists and is not empty with:
Now simply save this file in multiple locations as per your normal company backup procedures, and repeat this procedure on a regular basis as is appropriate.
Backing up Cassandra¶
Cassandra stores things such as user profiles/accounts, conversations, etc. It is the most critical data to backup/store/recover.
To backup your Cassandra database, do as follows:
You can read general information about connecting to your Cassandra node on this page
In particular, SSH into the Cassandra Virtual Machine with:
Where:
user
is the user you used to install Wire on this server, typicallywire
orroot
cassandra-vm.your-domain.com
is the domain name or IP address for the server with your Cassandra node
Make sure (while connected via ssh) your Cassandra installation is doing well with:
or (in newer versions)
You should see a list of nodes like this:
As per the Cassandra documentation to backup your database, you will use the nodetool snapshot
command.
First we need to edit the cassandra.yaml
file (which you can if needed find with find -name cassandra.yaml
) has auto_snapshot
set to false
:
Same with: snapshot_before_compaction
After editing the file, make sure you restart cassandra with:
You can find a list of all keyspaces by doing:
Now (while connected via ssh, as per above), use nodetool to actually generate a snapshot of all tables:
This should succesfully save the snapshots to the disk.
You should now be able to find your snapshots in the snapshots list with:
To actually save the files, you’ll need to locate them with:
Which should give you a list of paths to snapshots, such as:
Now to create a (local) backup of these snapshots, we use ssh
the same way we did above for wire-server
:
Where :
user
is the user you used to install Wire on this server, typicallywire
orroot
cassandra-vm.your-domain.com
is the domain name or IP address for the server with your Wire install/mnt/cassandra/
is the (absolute) path, on the server, where your cassandra folder is located, to which you add the location of the specific snapshot, found withfind
above
Repeat this for each of the snapshots.
Now simply save these files in multiple locations as per your normal company backup procedures, and repeat this procedure on a regular basis as is appropriate.
Batch Cassandra backup¶
The backup procedure above presumes manually backing up each Cassandra snapshot serially one by one.
If you want to back all files at once, you can use the find
command to find all snapshots and pack them into a single archive:
user
is the user you used to install Wire on this server, typicallywire
orroot
cassandra-vm.your-domain.com
is the domain name or IP address for the server with your Wire install/mnt/cassandra/
is the (absolute) path, on the server, where your cassandra folder is located, to which you add the location of the specific snapshot, found withfind
abovecassandra-batch.tar.gz
is the local file everything will be written to
This will (over ssh) find all snapshot
folders in the cassandra
folder, pack them into a tar file, gzip it to save space, and output it to a local file.
Backing up MinIO¶
MinIO emulates an Amazon-S3-compatible file-storage setup, and is used by Wire to store things such as file attachments, images etc.
If your specific installation is using the actual Amazon file storage (and not a local emulated alternative), you should skip this section (but still actually backup whatever you are using).
Similarly to Cassandra, to create a backup you need to SSH into the Virtual Machine running MinIO in your installation:
You can read general information about your MinIO node on this page.
SSH into the MinIO Virtual Machine with:
Where:
user
is the user you used to install Wire on this server, typicallywire
orroot
minio-vm.your-domain.com
is the domain name or IP address for the server with your MinIO node
To backup the MinIO data, we need to backup two servers over SSH, the same way we did for Cassandra and wire-server:
Where:
user
is the user you used to install Wire on this server, typicallywire
orroot
my-minio-server.your-domain.com
is the domain name or IP address for the MinIO Virtual Machineminio-server[number]-backup.tar.gz
is the name of the file in which each minio data folder will be stored
Automated regular backups¶
It is important to back up as often as possible. You can use cron
to automatically run your backup commands on a regular basis.
For example, you can create the following shell script, and write it to /home/myuser/backup/wire-backup.sh
:
Make the file executable with:
You can then manually run the file with:
As a test, run the script manually to make sure it actually properly does its job without any errors.
Then, you can add this to your cron file (by running crontab -e
) to make sure this commands gets executed on a regular basis (here we will use an hourly backup):
Your backup should now happen every hour automatically, ensuring you always have a backup at least an hour fresh in case of an emergency.
There are ways to have incremental backups and to do more complex/refined backup procedure, but those are beyond the scope of this document. You should check out Borg.
You should also set up your monitoring software (for example Nagios) to check whether your backup file is older than an hour, and if it is (meaning something went wrong), warn you immediately.
Recovery procedure¶
If the worse has happened, and you need to recover/restore your Wire installation, you will need to do the following:
- Create a new Wire installation from scratch (following this website or other customer-specific on-premise instructions you used the first time around).
- While creating this new wire installation, instead of using a fresh/empty
wire-server
folder, you use thewire-server
folder you backed up above (as it contains yourvalues
andsecret
files among other important files). - Restore your Cassandra backup files over your new Cassandra installation.
- Restore your MinIO backup files over your new MinIO installation.
- Restart all services.
- Ensure all services are functioning correctly
Restoring Wire-Server from a backup¶
If you correctly backup up your wire-server
installation, you should have access to a file named wire-server-backup.tar.gz
(see above).
You can extract this file to the remote machine with the following command:
Where :
wire-server-backup.tar.gz
is the name of the file in which your wire-server folder has been storedmy-wire-server.your-domain.com
is the domain name or IP address for the server with your Wire installuser
is the user you used to install Wire on this server, typicallywire
orroot
/path/to/my/folder/for/wire-server/
is the (absolute) path, on the server, where your wire-server folder is located
Now all files should be in their proper place, with the proper values, and you should be able to run the required ansible/helm commands that will result in a full installation of Wire.
Restoring Cassandra from a backup¶
If you correctly backed up your Cassandra database, you should have a series of snapshot
files, which you now need to restore over your “fresh” (ie. empty) Cassandra installation.
This page from the Cassandra documentation goes over how to restore from snapshots.
You should have lots of snapshots from the backup process. This example will go over how to restore one of the snapshots, but you should do this process for each and every snapshot you backup up.
First, transfer and extract the snapshot to the Cassandra Virtual Machine:
Now the folder /mnt/cassandra/data/data/catalogkeyspace/journal-296a2d30c22a11e9b1350d927649052c/snapshots/
should contain your snapshot.
Next, ssh into the Cassandra Virtual Machine and cd to the snapshot folder:
Next run
This will show you a list of the snapshots available:
Select the most recent one (here it is 1653752759667
).
Finally, use the sstableloader
file to load the snapshot to Cassandra:
This should load the snapshot.
Repeat this for all snapshots you saved, and you should have a fully restored Cassandra database.
Finally, restart Cassandra:
And ensure that it is working properly.
Restoring MinIO from a backup¶
Restoring MinIO from a backup is as simple as extracting the files (minio-server1-backup.tar.gz
and minio-server2-backup.tar.gz
which you have backup up in the backup procedure and should have access to) to the correct remote host (MinIO Virtual Machine), and restarting MinIO:
First run:
Where:
user
is the user you used to install Wire on this server, typicallywire
orroot
my-minio-server.your-domain.com
is the domain name or IP address for the MinIO Virtual Machineminio-server[number]-backup.tar.gz
is the name of the file in which each minio data folder was be stored and backup up
Finally SSH into the server and restart MinIO:
Where:
user
is the user you used to install Wire on this server, typicallywire
orroot
minio-vm.your-domain.com
is the domain name or IP address for the server with your MinIO node