Add Databases to an Availability Group

Add Databases to an Availability Group

In the primary replica, restore the database.

image-20220608094437985
image-20220608095913496

Change the Recovery Model to Full.

image-20220608100229708

Run the script to make full backups and tlog backups.

1
2
3
4
5
6
7
8
9
10
11
12
13
--Full Backups
BACKUP DATABASE [WideWorldImporters] TO DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL15.SQL1\MSSQL\Backup\WideWorldImporters_FullBackup_20220608.bak'
WITH NOFORMAT, NOINIT,
NAME = N'WideWorldImporters-Full Database Backup',
SKIP, NOREWIND, NOUNLOAD, COMPRESSION, STATS = 10, CHECKSUM
GO

--Tlog Backups
BACKUP LOG [WideWorldImporters] TO DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL15.SQL1\MSSQL\Backup\WideWorldImporters_TlogBackup_20220608.trn'
WITH NOFORMAT, NOINIT,
NAME = N'WideWorldImporters-Full Database Backup',
SKIP, NOREWIND, NOUNLOAD, COMPRESSION, STATS = 10, CHECKSUM
GO

In the Properties page of the AG, add the name of the database, then click on OK, if there is no warning, then we successfully added an additional database to the AG.

image-20220608100051919
image-20220608100634388

Add Databases to an Availability Group
http://example.com/2022/06/08/Add Database to an Availability Group/
Author
Jiacheng Xie
Posted on
June 8, 2022
Licensed under