Hi There!
Today's post is about fixing databases that are in a restoring state.
Scenario A
I have added a couple of databases to an availability group on my primary server.
When I go to the replica server, the databases show that they are in a restoring state.
Here's how to fix this issue:
I.
On the secondary server in SSMS, expand 'AlwaysOn High Availability' > 'Availability Groups' > ServerName (secondary) > 'Availability Databases' > right click your database name > 'Join to Availability Group...' >hit OK.
Now I have to go back to the primary server and take a fresh transaction log backup of the database again. Then copy the backup (.bak) file to the secondary server.
Today's post is about fixing databases that are in a restoring state.
Scenario A
I have added a couple of databases to an availability group on my primary server.
When I go to the replica server, the databases show that they are in a restoring state.
Here's how to fix this issue:
I.
On the secondary server in SSMS, expand 'AlwaysOn High Availability' > 'Availability Groups' > ServerName (secondary) > 'Availability Databases' > right click your database name > 'Join to Availability Group...' >hit OK.
When I hit OK above, I received a new error; SQL error 1408.
The error reads:
The error reads:
The remote copy of the database is not recovered far enough to enable database mirroring or to join it to the availability group. You need to apply missing log records to the remote database by restoring the current log backups from the principal/primary database.
Now I have to go back to the primary server and take a fresh transaction log backup of the database again. Then copy the backup (.bak) file to the secondary server.
Note: Step 1 would have been fine if I tried to join the database to the availability group immediately after the database was backed up. However, since the backup was days ago, the transaction log chain is too far apart/broken.
In SSMS, right click your database > task > restore > database > device > on the General page, find the backup you copied to your server > on the Files page, check the option to relocate all files to folder > On the Options page, check the option to Overwrite the existing database (WITH REPLACE) and the recovery state is RESTORE WITH NORECOVERY > hit OK.
III.
Go back and repeat step 1.
Success! Your database is now in sync on the secondary server.
Scenario B
I have added a couple of databases to an availability group on my primary server.
When I go to the replica server, the databases do not exist.
I.
On the primary server, take a full backup of the database (.bak). Then take a transaction log backup of the database (.trn). Copy both files to the secondary server.
II.
On the secondary server, restore the full backup first:
In SSMS, right click your database > task > restore > database > device > on the General page, find the backup you copied to your server > on the Files page, check the option to relocate all files to folder > On the Options page, do not check the option to Overwrite the existing database (WITH REPLACE) but make sure the recovery state is RESTORE WITH NORECOVERY > hit OK.
Then restore the transaction log:
In SSMS, right click your database > task > restore > database > device > on the General page, find the backup you copied to your server > on the Files page, check the option to relocate all files to folder > On the Options page, check the option to Overwrite the existing database (WITH REPLACE) and the recovery state is RESTORE WITH NORECOVERY > hit OK.
III.
(This is the same as Step 1 from scenario A)
On the secondary server in SSMS, expand 'AlwaysOn High Availability' > 'Availability Groups' > ServerName (secondary) > 'Availability Databases' > right click your database name > 'Join to Availability Group...' >hit OK.
Success! Your database is now in sync on the secondary server.
If you have any further questions, please post below.
Thank you and Happy reading,
-marshé hutchinson
#learnSQLwithme
When I go to the replica server, the databases do not exist.
I.
On the primary server, take a full backup of the database (.bak). Then take a transaction log backup of the database (.trn). Copy both files to the secondary server.
II.
On the secondary server, restore the full backup first:
In SSMS, right click your database > task > restore > database > device > on the General page, find the backup you copied to your server > on the Files page, check the option to relocate all files to folder > On the Options page, do not check the option to Overwrite the existing database (WITH REPLACE) but make sure the recovery state is RESTORE WITH NORECOVERY > hit OK.
Then restore the transaction log:
In SSMS, right click your database > task > restore > database > device > on the General page, find the backup you copied to your server > on the Files page, check the option to relocate all files to folder > On the Options page, check the option to Overwrite the existing database (WITH REPLACE) and the recovery state is RESTORE WITH NORECOVERY > hit OK.
III.
(This is the same as Step 1 from scenario A)
On the secondary server in SSMS, expand 'AlwaysOn High Availability' > 'Availability Groups' > ServerName (secondary) > 'Availability Databases' > right click your database name > 'Join to Availability Group...' >hit OK.
Success! Your database is now in sync on the secondary server.
If you have any further questions, please post below.
Thank you and Happy reading,
-marshé hutchinson
#learnSQLwithme
Comments
Post a Comment