Is it possible to offline the database then taking backup using sql job?Restore the latest backup on the databaseDB2 Online Restore but Without Roll Forward?Error while taking backup using SSMSSql Server Backup Job failedFixing an error 9004 without taking the database offlineMaintenance plan backup and reload the same databaseDB2 - question regarding RESTORE OFFLINE backup and Archive LogsDatabase backup issue in SQL ServerRestoring Database, creating new copy and use existing transaction logs for the original backup database to restore the NEW database to be current?Find when a specific database went offline and the reason for same
How JS split works on arabic plus english number strings?
My machine, client installed VPN,
Would a 737 pilot use flaps in nose dive?
Whaling ship logistics
Detail vs. filler
Delete n lines skip 1 line script
How much horsepower to weight is required for a 1:1 thrust ratio?
Smallest PRIME containing the first 11 primes as sub-strings
Contour integration with infinite poles
Why is the population of post-Soviet states declining?
A word that refers to saying something in an attempt to anger or embarrass someone into doing something that they don’t want to do?
Can I exile my opponent's Progenitus/True-Name Nemesis with Teferi, Hero of Dominaria's emblem?
Science fiction episode about the creation of a living pegasus, even though flightless
Can an energy drink or chocolate before an exam be useful ? What sort of other edible goods be helpful?
After viewing logs with journalctl, how do I exit the screen that says "lines 1-2/2 (END)"?
My first Hangman game in Python
What is the meaning of colored vials next to some passive skills
Is it ok if I haven't decided my research topic when I first meet with a potential phd advisor?
Is there a relationship between prime numbers and music?
Is determiner 'a' needed in "one would call such a value a constant"?
rust-proof solution for attaching 2x4 to 4x4?
Why does Captain Marvel in the MCU not have her sash?
Create the same subfolders in another folder
Does AES-ECB with random padding added to each block satisfy IND-CPA?
Is it possible to offline the database then taking backup using sql job?
Restore the latest backup on the databaseDB2 Online Restore but Without Roll Forward?Error while taking backup using SSMSSql Server Backup Job failedFixing an error 9004 without taking the database offlineMaintenance plan backup and reload the same databaseDB2 - question regarding RESTORE OFFLINE backup and Archive LogsDatabase backup issue in SQL ServerRestoring Database, creating new copy and use existing transaction logs for the original backup database to restore the NEW database to be current?Find when a specific database went offline and the reason for same
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have the scenario where I have to generate a backup of the database(MSSQL-2008) and restore into the new server (MSSQL-2016). While taking backup data should not be changed in any case. So I have two options to do that, but I am not sure how it will work. (Everything is using SQL Job only)
Set Read-Only database and restore into new DB server.
→ Is it possible to restore read-only DB in the new server? The destination server is already having a Read-Write(Online) database by the same name.
Set Offline database and restore into new DB server.
→ Is it possible to restore offline DB in the new server? the destination server is already having Online (Read-Write) database by the same name.
If anyone can share his view on this, Thank you in advance.
sql-server sql-server-2008-r2 backup sql-server-2016
add a comment
|
I have the scenario where I have to generate a backup of the database(MSSQL-2008) and restore into the new server (MSSQL-2016). While taking backup data should not be changed in any case. So I have two options to do that, but I am not sure how it will work. (Everything is using SQL Job only)
Set Read-Only database and restore into new DB server.
→ Is it possible to restore read-only DB in the new server? The destination server is already having a Read-Write(Online) database by the same name.
Set Offline database and restore into new DB server.
→ Is it possible to restore offline DB in the new server? the destination server is already having Online (Read-Write) database by the same name.
If anyone can share his view on this, Thank you in advance.
sql-server sql-server-2008-r2 backup sql-server-2016
Generally rolling forward 3 (or 4) versions of SQLServer will not work, you can only roll forward 2 versions. ie 2008 -> 2012, 2008r2 -> 2014, 2012 -> 2016
– Trubs
8 hours ago
2
@Trubs I am not sure your statement is correct. You can upgrade instances of SQL Server 2008,..... to SQL Server 2017.
– James Jenkins
5 hours ago
1
@Trubs: Version upgrading is not my actual problem. But as @ James have shared the reference link, 2008 to 2016 is never been an issue.
– Irfan
4 hours ago
add a comment
|
I have the scenario where I have to generate a backup of the database(MSSQL-2008) and restore into the new server (MSSQL-2016). While taking backup data should not be changed in any case. So I have two options to do that, but I am not sure how it will work. (Everything is using SQL Job only)
Set Read-Only database and restore into new DB server.
→ Is it possible to restore read-only DB in the new server? The destination server is already having a Read-Write(Online) database by the same name.
Set Offline database and restore into new DB server.
→ Is it possible to restore offline DB in the new server? the destination server is already having Online (Read-Write) database by the same name.
If anyone can share his view on this, Thank you in advance.
sql-server sql-server-2008-r2 backup sql-server-2016
I have the scenario where I have to generate a backup of the database(MSSQL-2008) and restore into the new server (MSSQL-2016). While taking backup data should not be changed in any case. So I have two options to do that, but I am not sure how it will work. (Everything is using SQL Job only)
Set Read-Only database and restore into new DB server.
→ Is it possible to restore read-only DB in the new server? The destination server is already having a Read-Write(Online) database by the same name.
Set Offline database and restore into new DB server.
→ Is it possible to restore offline DB in the new server? the destination server is already having Online (Read-Write) database by the same name.
If anyone can share his view on this, Thank you in advance.
sql-server sql-server-2008-r2 backup sql-server-2016
sql-server sql-server-2008-r2 backup sql-server-2016
asked 8 hours ago
IrfanIrfan
1297 bronze badges
1297 bronze badges
Generally rolling forward 3 (or 4) versions of SQLServer will not work, you can only roll forward 2 versions. ie 2008 -> 2012, 2008r2 -> 2014, 2012 -> 2016
– Trubs
8 hours ago
2
@Trubs I am not sure your statement is correct. You can upgrade instances of SQL Server 2008,..... to SQL Server 2017.
– James Jenkins
5 hours ago
1
@Trubs: Version upgrading is not my actual problem. But as @ James have shared the reference link, 2008 to 2016 is never been an issue.
– Irfan
4 hours ago
add a comment
|
Generally rolling forward 3 (or 4) versions of SQLServer will not work, you can only roll forward 2 versions. ie 2008 -> 2012, 2008r2 -> 2014, 2012 -> 2016
– Trubs
8 hours ago
2
@Trubs I am not sure your statement is correct. You can upgrade instances of SQL Server 2008,..... to SQL Server 2017.
– James Jenkins
5 hours ago
1
@Trubs: Version upgrading is not my actual problem. But as @ James have shared the reference link, 2008 to 2016 is never been an issue.
– Irfan
4 hours ago
Generally rolling forward 3 (or 4) versions of SQLServer will not work, you can only roll forward 2 versions. ie 2008 -> 2012, 2008r2 -> 2014, 2012 -> 2016
– Trubs
8 hours ago
Generally rolling forward 3 (or 4) versions of SQLServer will not work, you can only roll forward 2 versions. ie 2008 -> 2012, 2008r2 -> 2014, 2012 -> 2016
– Trubs
8 hours ago
2
2
@Trubs I am not sure your statement is correct. You can upgrade instances of SQL Server 2008,..... to SQL Server 2017.
– James Jenkins
5 hours ago
@Trubs I am not sure your statement is correct. You can upgrade instances of SQL Server 2008,..... to SQL Server 2017.
– James Jenkins
5 hours ago
1
1
@Trubs: Version upgrading is not my actual problem. But as @ James have shared the reference link, 2008 to 2016 is never been an issue.
– Irfan
4 hours ago
@Trubs: Version upgrading is not my actual problem. But as @ James have shared the reference link, 2008 to 2016 is never been an issue.
– Irfan
4 hours ago
add a comment
|
3 Answers
3
active
oldest
votes
→ Is it possible to restore read-only DB in the new server?
Yes
An example:
CREATE DATABASE ReadOnlyDB;
GO
ALTER DATABASE ReadOnlyDB SET READ_ONLY;
BACKUP DATABASE ReadOnlyDB TO disk = '\sharereadonly.Bak';
destination server is already having a Read-Write(Online) database by
the same name.
Not entirely sure what you mean by this, but you could restore the database with a different name if you would like to, remember to remove the read only property afterwards.
RESTORE DATABASE ReadOnlyDB2
FROM DISK = '\sharereadonly.Bak'
WITH MOVE 'ReadOnlyDB' to 'DatalocationReadOnlyDB2.mdf',
MOVE 'ReadOnlyDB_log' to 'LoglocationReadOnlyDB_log2.ldf',
STATS = 5;
GO
ALTER DATABASE ReadOnlyDB2 SET READ_WRITE;
You could also replace the existing database with the REPLACE keyword.
→ Is it possible to restore offline DB in the new server?
No, this is not possible as sql server removes all handles from the database files and will not be able to access it while it is offline.
ALTER DATABASE ReadOnlyDB SET OFFLINE WITH ROLLBACK IMMEDIATE;
GO
BACKUP DATABASE ReadOnlyDB TO disk = 'C:tempreadonlyOffline.Bak';
Msg 942, Level 14, State 4, Line 10 Database 'ReadOnlyDB' cannot be
opened because it is offline. Msg 3013, Level 16, State 1, Line 10
BACKUP DATABASE is terminating abnormally.
You could look into detach / attach but backup restore is preferable.
SQL code was not actually needed but thanks you explained everything in detail. I think doing a Read-Only will be the safest option for me to execute.
– Irfan
5 hours ago
add a comment
|
Yoy have a couple of options in your situation:
- Turn off applications that can change data in the database
- Set the database in single user mode and back it up. Something like this:
ALTER DATABASE [<DBName>] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
BACKUP DATABASE [<DBName>] TO DISK = N'<locationAndFilename>'
Then restore it and redirect the app to the new server
I suggest doing SINGLE USER mode, maybe at the end. or simply change the login password or disable logins Either way, backup will backup to the end of backup operation so all changes are captured (e.g. if you start at 1pm, takes 1 hour to backup finishing at 2 pm, your backup will contain everything until 2 pm anyway)
– Jerry Hung
8 hours ago
add a comment
|
I am not fully understanding your situation. There are a couple of things not mentioned in the question or existing answers.
While taking backup data should not be changed in any case.
Why? - Any changes that are made during the backup are captured and included in the backup. So if it takes 2 hours for the backup to complete, all the changes made during that 2 hours will be included in the backup. Both will match as of the instant the backup completes.
Assuming (opposite of above) that you want a backup that is effective as of a start time, rather then an end time. And as you mentioned setting the database offline, I assume you are fine with no one having access during the backup.
If there is only one database on the server, use a job step to disable their logins at the server, when the backup is complete, re-enable.
USE [master]
EXEC asp_kill_user_connections [myDatabase] --This is sp that kills all user connects to a database, it is in house and I don't have the rights to share its code, but you can make your own.
USE master
REVOKE CONNECT SQL TO [AD/SomeGroupAccount]
ALTER LOGIN [SomeSQLAuthAccount] DISABLE
GO
Do your backup, and when it is done give them access again.
add a comment
|
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "182"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f249465%2fis-it-possible-to-offline-the-database-then-taking-backup-using-sql-job%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
→ Is it possible to restore read-only DB in the new server?
Yes
An example:
CREATE DATABASE ReadOnlyDB;
GO
ALTER DATABASE ReadOnlyDB SET READ_ONLY;
BACKUP DATABASE ReadOnlyDB TO disk = '\sharereadonly.Bak';
destination server is already having a Read-Write(Online) database by
the same name.
Not entirely sure what you mean by this, but you could restore the database with a different name if you would like to, remember to remove the read only property afterwards.
RESTORE DATABASE ReadOnlyDB2
FROM DISK = '\sharereadonly.Bak'
WITH MOVE 'ReadOnlyDB' to 'DatalocationReadOnlyDB2.mdf',
MOVE 'ReadOnlyDB_log' to 'LoglocationReadOnlyDB_log2.ldf',
STATS = 5;
GO
ALTER DATABASE ReadOnlyDB2 SET READ_WRITE;
You could also replace the existing database with the REPLACE keyword.
→ Is it possible to restore offline DB in the new server?
No, this is not possible as sql server removes all handles from the database files and will not be able to access it while it is offline.
ALTER DATABASE ReadOnlyDB SET OFFLINE WITH ROLLBACK IMMEDIATE;
GO
BACKUP DATABASE ReadOnlyDB TO disk = 'C:tempreadonlyOffline.Bak';
Msg 942, Level 14, State 4, Line 10 Database 'ReadOnlyDB' cannot be
opened because it is offline. Msg 3013, Level 16, State 1, Line 10
BACKUP DATABASE is terminating abnormally.
You could look into detach / attach but backup restore is preferable.
SQL code was not actually needed but thanks you explained everything in detail. I think doing a Read-Only will be the safest option for me to execute.
– Irfan
5 hours ago
add a comment
|
→ Is it possible to restore read-only DB in the new server?
Yes
An example:
CREATE DATABASE ReadOnlyDB;
GO
ALTER DATABASE ReadOnlyDB SET READ_ONLY;
BACKUP DATABASE ReadOnlyDB TO disk = '\sharereadonly.Bak';
destination server is already having a Read-Write(Online) database by
the same name.
Not entirely sure what you mean by this, but you could restore the database with a different name if you would like to, remember to remove the read only property afterwards.
RESTORE DATABASE ReadOnlyDB2
FROM DISK = '\sharereadonly.Bak'
WITH MOVE 'ReadOnlyDB' to 'DatalocationReadOnlyDB2.mdf',
MOVE 'ReadOnlyDB_log' to 'LoglocationReadOnlyDB_log2.ldf',
STATS = 5;
GO
ALTER DATABASE ReadOnlyDB2 SET READ_WRITE;
You could also replace the existing database with the REPLACE keyword.
→ Is it possible to restore offline DB in the new server?
No, this is not possible as sql server removes all handles from the database files and will not be able to access it while it is offline.
ALTER DATABASE ReadOnlyDB SET OFFLINE WITH ROLLBACK IMMEDIATE;
GO
BACKUP DATABASE ReadOnlyDB TO disk = 'C:tempreadonlyOffline.Bak';
Msg 942, Level 14, State 4, Line 10 Database 'ReadOnlyDB' cannot be
opened because it is offline. Msg 3013, Level 16, State 1, Line 10
BACKUP DATABASE is terminating abnormally.
You could look into detach / attach but backup restore is preferable.
SQL code was not actually needed but thanks you explained everything in detail. I think doing a Read-Only will be the safest option for me to execute.
– Irfan
5 hours ago
add a comment
|
→ Is it possible to restore read-only DB in the new server?
Yes
An example:
CREATE DATABASE ReadOnlyDB;
GO
ALTER DATABASE ReadOnlyDB SET READ_ONLY;
BACKUP DATABASE ReadOnlyDB TO disk = '\sharereadonly.Bak';
destination server is already having a Read-Write(Online) database by
the same name.
Not entirely sure what you mean by this, but you could restore the database with a different name if you would like to, remember to remove the read only property afterwards.
RESTORE DATABASE ReadOnlyDB2
FROM DISK = '\sharereadonly.Bak'
WITH MOVE 'ReadOnlyDB' to 'DatalocationReadOnlyDB2.mdf',
MOVE 'ReadOnlyDB_log' to 'LoglocationReadOnlyDB_log2.ldf',
STATS = 5;
GO
ALTER DATABASE ReadOnlyDB2 SET READ_WRITE;
You could also replace the existing database with the REPLACE keyword.
→ Is it possible to restore offline DB in the new server?
No, this is not possible as sql server removes all handles from the database files and will not be able to access it while it is offline.
ALTER DATABASE ReadOnlyDB SET OFFLINE WITH ROLLBACK IMMEDIATE;
GO
BACKUP DATABASE ReadOnlyDB TO disk = 'C:tempreadonlyOffline.Bak';
Msg 942, Level 14, State 4, Line 10 Database 'ReadOnlyDB' cannot be
opened because it is offline. Msg 3013, Level 16, State 1, Line 10
BACKUP DATABASE is terminating abnormally.
You could look into detach / attach but backup restore is preferable.
→ Is it possible to restore read-only DB in the new server?
Yes
An example:
CREATE DATABASE ReadOnlyDB;
GO
ALTER DATABASE ReadOnlyDB SET READ_ONLY;
BACKUP DATABASE ReadOnlyDB TO disk = '\sharereadonly.Bak';
destination server is already having a Read-Write(Online) database by
the same name.
Not entirely sure what you mean by this, but you could restore the database with a different name if you would like to, remember to remove the read only property afterwards.
RESTORE DATABASE ReadOnlyDB2
FROM DISK = '\sharereadonly.Bak'
WITH MOVE 'ReadOnlyDB' to 'DatalocationReadOnlyDB2.mdf',
MOVE 'ReadOnlyDB_log' to 'LoglocationReadOnlyDB_log2.ldf',
STATS = 5;
GO
ALTER DATABASE ReadOnlyDB2 SET READ_WRITE;
You could also replace the existing database with the REPLACE keyword.
→ Is it possible to restore offline DB in the new server?
No, this is not possible as sql server removes all handles from the database files and will not be able to access it while it is offline.
ALTER DATABASE ReadOnlyDB SET OFFLINE WITH ROLLBACK IMMEDIATE;
GO
BACKUP DATABASE ReadOnlyDB TO disk = 'C:tempreadonlyOffline.Bak';
Msg 942, Level 14, State 4, Line 10 Database 'ReadOnlyDB' cannot be
opened because it is offline. Msg 3013, Level 16, State 1, Line 10
BACKUP DATABASE is terminating abnormally.
You could look into detach / attach but backup restore is preferable.
edited 7 hours ago
answered 7 hours ago
Randi VertongenRandi Vertongen
9,3593 gold badges12 silver badges33 bronze badges
9,3593 gold badges12 silver badges33 bronze badges
SQL code was not actually needed but thanks you explained everything in detail. I think doing a Read-Only will be the safest option for me to execute.
– Irfan
5 hours ago
add a comment
|
SQL code was not actually needed but thanks you explained everything in detail. I think doing a Read-Only will be the safest option for me to execute.
– Irfan
5 hours ago
SQL code was not actually needed but thanks you explained everything in detail. I think doing a Read-Only will be the safest option for me to execute.
– Irfan
5 hours ago
SQL code was not actually needed but thanks you explained everything in detail. I think doing a Read-Only will be the safest option for me to execute.
– Irfan
5 hours ago
add a comment
|
Yoy have a couple of options in your situation:
- Turn off applications that can change data in the database
- Set the database in single user mode and back it up. Something like this:
ALTER DATABASE [<DBName>] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
BACKUP DATABASE [<DBName>] TO DISK = N'<locationAndFilename>'
Then restore it and redirect the app to the new server
I suggest doing SINGLE USER mode, maybe at the end. or simply change the login password or disable logins Either way, backup will backup to the end of backup operation so all changes are captured (e.g. if you start at 1pm, takes 1 hour to backup finishing at 2 pm, your backup will contain everything until 2 pm anyway)
– Jerry Hung
8 hours ago
add a comment
|
Yoy have a couple of options in your situation:
- Turn off applications that can change data in the database
- Set the database in single user mode and back it up. Something like this:
ALTER DATABASE [<DBName>] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
BACKUP DATABASE [<DBName>] TO DISK = N'<locationAndFilename>'
Then restore it and redirect the app to the new server
I suggest doing SINGLE USER mode, maybe at the end. or simply change the login password or disable logins Either way, backup will backup to the end of backup operation so all changes are captured (e.g. if you start at 1pm, takes 1 hour to backup finishing at 2 pm, your backup will contain everything until 2 pm anyway)
– Jerry Hung
8 hours ago
add a comment
|
Yoy have a couple of options in your situation:
- Turn off applications that can change data in the database
- Set the database in single user mode and back it up. Something like this:
ALTER DATABASE [<DBName>] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
BACKUP DATABASE [<DBName>] TO DISK = N'<locationAndFilename>'
Then restore it and redirect the app to the new server
Yoy have a couple of options in your situation:
- Turn off applications that can change data in the database
- Set the database in single user mode and back it up. Something like this:
ALTER DATABASE [<DBName>] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
BACKUP DATABASE [<DBName>] TO DISK = N'<locationAndFilename>'
Then restore it and redirect the app to the new server
answered 8 hours ago
George KGeorge K
1,6067 silver badges20 bronze badges
1,6067 silver badges20 bronze badges
I suggest doing SINGLE USER mode, maybe at the end. or simply change the login password or disable logins Either way, backup will backup to the end of backup operation so all changes are captured (e.g. if you start at 1pm, takes 1 hour to backup finishing at 2 pm, your backup will contain everything until 2 pm anyway)
– Jerry Hung
8 hours ago
add a comment
|
I suggest doing SINGLE USER mode, maybe at the end. or simply change the login password or disable logins Either way, backup will backup to the end of backup operation so all changes are captured (e.g. if you start at 1pm, takes 1 hour to backup finishing at 2 pm, your backup will contain everything until 2 pm anyway)
– Jerry Hung
8 hours ago
I suggest doing SINGLE USER mode, maybe at the end. or simply change the login password or disable logins Either way, backup will backup to the end of backup operation so all changes are captured (e.g. if you start at 1pm, takes 1 hour to backup finishing at 2 pm, your backup will contain everything until 2 pm anyway)
– Jerry Hung
8 hours ago
I suggest doing SINGLE USER mode, maybe at the end. or simply change the login password or disable logins Either way, backup will backup to the end of backup operation so all changes are captured (e.g. if you start at 1pm, takes 1 hour to backup finishing at 2 pm, your backup will contain everything until 2 pm anyway)
– Jerry Hung
8 hours ago
add a comment
|
I am not fully understanding your situation. There are a couple of things not mentioned in the question or existing answers.
While taking backup data should not be changed in any case.
Why? - Any changes that are made during the backup are captured and included in the backup. So if it takes 2 hours for the backup to complete, all the changes made during that 2 hours will be included in the backup. Both will match as of the instant the backup completes.
Assuming (opposite of above) that you want a backup that is effective as of a start time, rather then an end time. And as you mentioned setting the database offline, I assume you are fine with no one having access during the backup.
If there is only one database on the server, use a job step to disable their logins at the server, when the backup is complete, re-enable.
USE [master]
EXEC asp_kill_user_connections [myDatabase] --This is sp that kills all user connects to a database, it is in house and I don't have the rights to share its code, but you can make your own.
USE master
REVOKE CONNECT SQL TO [AD/SomeGroupAccount]
ALTER LOGIN [SomeSQLAuthAccount] DISABLE
GO
Do your backup, and when it is done give them access again.
add a comment
|
I am not fully understanding your situation. There are a couple of things not mentioned in the question or existing answers.
While taking backup data should not be changed in any case.
Why? - Any changes that are made during the backup are captured and included in the backup. So if it takes 2 hours for the backup to complete, all the changes made during that 2 hours will be included in the backup. Both will match as of the instant the backup completes.
Assuming (opposite of above) that you want a backup that is effective as of a start time, rather then an end time. And as you mentioned setting the database offline, I assume you are fine with no one having access during the backup.
If there is only one database on the server, use a job step to disable their logins at the server, when the backup is complete, re-enable.
USE [master]
EXEC asp_kill_user_connections [myDatabase] --This is sp that kills all user connects to a database, it is in house and I don't have the rights to share its code, but you can make your own.
USE master
REVOKE CONNECT SQL TO [AD/SomeGroupAccount]
ALTER LOGIN [SomeSQLAuthAccount] DISABLE
GO
Do your backup, and when it is done give them access again.
add a comment
|
I am not fully understanding your situation. There are a couple of things not mentioned in the question or existing answers.
While taking backup data should not be changed in any case.
Why? - Any changes that are made during the backup are captured and included in the backup. So if it takes 2 hours for the backup to complete, all the changes made during that 2 hours will be included in the backup. Both will match as of the instant the backup completes.
Assuming (opposite of above) that you want a backup that is effective as of a start time, rather then an end time. And as you mentioned setting the database offline, I assume you are fine with no one having access during the backup.
If there is only one database on the server, use a job step to disable their logins at the server, when the backup is complete, re-enable.
USE [master]
EXEC asp_kill_user_connections [myDatabase] --This is sp that kills all user connects to a database, it is in house and I don't have the rights to share its code, but you can make your own.
USE master
REVOKE CONNECT SQL TO [AD/SomeGroupAccount]
ALTER LOGIN [SomeSQLAuthAccount] DISABLE
GO
Do your backup, and when it is done give them access again.
I am not fully understanding your situation. There are a couple of things not mentioned in the question or existing answers.
While taking backup data should not be changed in any case.
Why? - Any changes that are made during the backup are captured and included in the backup. So if it takes 2 hours for the backup to complete, all the changes made during that 2 hours will be included in the backup. Both will match as of the instant the backup completes.
Assuming (opposite of above) that you want a backup that is effective as of a start time, rather then an end time. And as you mentioned setting the database offline, I assume you are fine with no one having access during the backup.
If there is only one database on the server, use a job step to disable their logins at the server, when the backup is complete, re-enable.
USE [master]
EXEC asp_kill_user_connections [myDatabase] --This is sp that kills all user connects to a database, it is in house and I don't have the rights to share its code, but you can make your own.
USE master
REVOKE CONNECT SQL TO [AD/SomeGroupAccount]
ALTER LOGIN [SomeSQLAuthAccount] DISABLE
GO
Do your backup, and when it is done give them access again.
answered 1 hour ago
James JenkinsJames Jenkins
2,8802 gold badges25 silver badges52 bronze badges
2,8802 gold badges25 silver badges52 bronze badges
add a comment
|
add a comment
|
Thanks for contributing an answer to Database Administrators Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f249465%2fis-it-possible-to-offline-the-database-then-taking-backup-using-sql-job%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Generally rolling forward 3 (or 4) versions of SQLServer will not work, you can only roll forward 2 versions. ie 2008 -> 2012, 2008r2 -> 2014, 2012 -> 2016
– Trubs
8 hours ago
2
@Trubs I am not sure your statement is correct. You can upgrade instances of SQL Server 2008,..... to SQL Server 2017.
– James Jenkins
5 hours ago
1
@Trubs: Version upgrading is not my actual problem. But as @ James have shared the reference link, 2008 to 2016 is never been an issue.
– Irfan
4 hours ago