A short bash script to backup Mattermosts database and data directory encrypted. It stores the backup archives in a specified destination directory.
You only need gnupg and tar installed.
Clone this repository anywhere, most common is /usr/local/sbin
cd /usr/local/sbin
git clone https://github.com/linuskohl/mattermost_backup
Make the script executable by running
chmod +x mattermost_backup.sh
Adapt the paths and settings in the mattermost_backup.sh file to your needs.
In order to encrypt the backups you need to generate a file containing your password. If you want to create a secure, random password you could use the following command, that generates a 500 character long random password and stores it in a key file.
gpg --gen-random --armor 2 500 > /etc/mattermost_backup.key
Prevent other users from reading or modifying the key
chown root:root /etc/mattermost_backup.key
chmod 600 /etc/mattermost_backup.key
Add the script to you crontab by running
crontab -e
and appending a line according to you backup schedule. A daily backup at midnight could look like this
0 0 * * * /usr/local/sbin/mattermost_backup/mattermost_backup.sh >/dev/null 2>&1
The project is licensed under the GPLv3 License. See LICENSE.txt for more details.
- Linus Kohl, linus@munichresearch.com