Knowledge Base

Browse our knowledge base for free solutions to common problems

Remote Backup For Bitwarden MSSQL Database

Created On: 14 September 2022
Written by: Ben

Nightly Database Backups

Bitwarden will automatically take nightly backups of the mssql container database. These database backups are kept in the ./bwdata/mssql/backups directory. Nightly database backups are kept in this directory for 30 days. In the event of data loss, you can restore one of these daily backups.

I wanted to sync these backups to a remote FTP server keeping them both in sync with rsync. In order to do this follow the steps below:

Install epel-release:

yum install epel-release -y

Install curlftpfs:

yum install curlftpfs -y

curlftpfs will allow us to mount an FTP space as if it was a filesystem so lets create a mount directory for this:

mkdir /ftp-mnt

In order to perform the mount it must be done via bash script so I created the following file:

touch /etc/init.d/ftp-mount

Then made the file executable:

chmod +x /etc/init.d/ftp-mount

The edit the bash script vi /etc/init.d/ftp-mount and add the following contents replacing ftpUser ftpPass ftpHost with your FTP details:

# Run-level Startup script for curlftpfs
# chkconfig: 345 91 19
# description: Startup/Shutdown the curlftpfs
# FTP user, password, and host (you can specify the port also eg.
# Mounted to folder
# Create the mounted to dir if doesn't exist
if [ ! -d $mPath ]; then
    mkdir -p $mPath
case "$1" in
        curlftpfs $ftpHost $mPath -o user=$ftpUser:$ftpPass,allow_other
        fusermount -u $mPath
        $0 stop
        $0 start
        echo "Usage: $0 start|stop|restart|reload"
        exit 1
exit 0

Now get it to auto start on boot:

chkconfig ftp-mount on

Start the service we just created:

service ftp-mount start

To restart and reload:

service ftp-mount restart
service ftp-mount reload

To stop:

service ftp-mount stop

You should be able to access the mount directory and see the data on the remote ftp server once the service is started:

cd /ftp-mnt/

Next I install rsync to handle syncing the two directories (/bwdata/mssql/backups and /ftp-mnt):

yum install rsync -y

Next I install rsync to handle syncing the two directories (/bwdata/mssql/backups and /ftp-mnt):

yum install rsync -y


ICTU LTD is a company registered England and Wales (Company No. 09344913) 15 Queen Square, Leeds, West Yorkshire, England, LS2 8AJ
Copyright © 2024 ICTU LTD, All Rights Reserved.