I have a lot of SharePoint 2013 databases to backup and if update fail to restore, so I want to automate this operations.
ALTER DATABASE [TEST_1] SET OFFLINE WITH ROLLBACK IMMEDIATE
GO
BACKUP DATABASE [TEST_1]
TO DISK = 'C:\path\test_1.bak' WITH NOINIT, STATS = 10
GO
ALTER DATABASE [TEST_1] SET ONLINE WITH ROLLBACK IMMEDIATE
But there is and error msg:
Msg 942, Level 14, State 4, Line 1
Database 'TEST_1' cannot be opened because it is offline.Msg 3013, Level 16, State 1, Line 1
BACKUP DATABASE is terminating abnormally.
Is it possbile to switch database offline, make backup and turn it in online mode after this?