Seekseekqua runs MSSQL for Linux, which is used by NCSBN and SOCRA.
It's important to note that the version of MSSQL is tied to the Ubuntu version. We run MSSQL 15, which requires Ubuntu 22.
Installation instructions may change by version. Please reference this article.
curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
add-apt-repository "$(wget -qO- https://packages.microsoft.com/config/ubuntu/20.04/mssql-server-2022.list)"
apt update
apt install -y mssql-server
Run the setup:
/opt/mssql/bin/mssql-conf setup
Select the “Web” edition and enter the SA password (Refer to keepassx file)
Install the CLI tools:
curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
apt update
apt install mssql-tools18
echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc
source ~/.bashrc
Note: You may need to install the older libs for ssl and ldap:
wget http://http.us.debian.org/debian/pool/main/o/openldap/libldap-2.4-2_2.4.47+dfsg-3+deb10u7_amd64.deb
wget https://nz2.archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.23_amd64.deb
apt install libldap-2.4-2_2.4.47+dfsg-3+deb10u7_amd64.deb libssl1.1_1.1.1f-1ubuntu2.23_amd64.deb
As there are no known applications for automatically backing up MSSQL databases on Linux, a shell script is used to run daily backups with a 7-day retention period:
/root/backup.sh
The backups run to the local backup server via an NFS mount to /backups
To restore a backup:
1. Decompress the backup:
cd /backups/daily/$day
gunzip $backup-name
2. Set ownership
chown mssql:mssql $backup-name
3. Restore backup
You'll need to enter the MSSQL CLI first:
/opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P '$sa_password' -C
Example restore:
RESTORE DATABASE NCSBN_Analysis_Dev
FROM DISK = '/backups/daily/15/NCSBN_Analysis.bak'
WITH MOVE 'TRANSOM_Demo' TO '/backups/daily/15/NCSBN_Analysis_Dev.mdf',
MOVE 'TRANSOM_Demo_log' TO '/backups/daily/15/NCSBN_Analysis_Dev_Log.ldf'
GO
Please note that in the above example, the database name in the backup may not match the actual database name, which is common when a database is copied or renamed. You'll need to use this name in the restore for the backup. You can usually find the internal database name with the following command:
RESTORE HEADERONLY FROM DISK='/path/to/backup.bak'