How can we help you today?

Remote Backup For Bitwarden MSSQL Database

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:

#!/bin/sh
#
# 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. ftp.example.com:2002)
ftpUser=user
ftpPass=password
ftpHost=ftp.example.com
 
# Mounted to folder
mPath="/ftp-mnt"
 
# Create the mounted to dir if doesn't exist
if [ ! -d $mPath ]; then
    mkdir -p $mPath
fi
 
case "$1" in
    start)
        curlftpfs $ftpHost $mPath -o user=$ftpUser:$ftpPass,allow_other
        ;;
    stop)
        fusermount -u $mPath
        ;;
    reload|restart)
        $0 stop
        $0 start
        ;;
    *)
        echo "Usage: $0 start|stop|restart|reload"
        exit 1
esac
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

 

Leave a Reply

Your email address will not be published. Required fields are marked *

    ICTU LTD is a company registered England and Wales (Company No. 09344913) 142 Thornes Lane, Wakefield, England, WF2 7RE
    Copyright © 2025 ICTU LTD, All Rights Reserved.