backup database

  • Comments posted to this topic are about the item backup database

  • Nice question thanks!

  • Some operations have no sense inside a transaction. I surprise to see so many wrong answers.

  • I guessed wrongly that because it makes no sense to do a backup within a transactiobn, then the transaction would be ignored and it would work.

    I'm not sure what the question was supposed to teach us though - would anybody really try doing a backup inside a transaction?!

  • Had to read through the BACKUP item in Books Online to be sure what would happen here, because it certainly makes no sense to put a backup inside a transaction and I had no idea what SQL would actually do if you tried!

  • I thought this was on error then rollback. I remember you could test a backup without anything really happening, just a test to see if the wirings, pipes and screws are correct.

  • Toreador (9/22/2010)


    I guessed wrongly that because it makes no sense to do a backup within a transactiobn, then the transaction would be ignored and it would work.

    I'm not sure what the question was supposed to teach us though - would anybody really try doing a backup inside a transaction?!

    Woo hoo, I finally got one right.

    Believe it or not, a simple Google search reveals people did try to run a backup within a transaction:

    http://www.sqlnewsgroups.net/sqlserver/t10622-commit-rollback.aspx

    What were they thinking?

  • I learned something. I thought that the backup would be OK, but the there would be no history for the backup in msdb.

    Good question.

  • Toreador (9/22/2010)


    I guessed wrongly that because it makes no sense to do a backup within a transactiobn, then the transaction would be ignored and it would work.

    My logic as well. Tough question.

  • I think the proper way to "rollback" a backup is to do a restore. 😉

  • Toreador (9/22/2010)


    ...I'm not sure what the question was supposed to teach us though - would anybody really try doing a backup inside a transaction?!

    Perhaps not intentionally, but indirectly: how many of you know what all of the stored procs on your systems actually do?

    I can think of no logical reason* for someone to include a backup within a stored proc that does something else, but if they did, and you didn't know it, and called the proc from within a transaction...

    *And since there's no logical reason to do it, it almost certainly has been done.

  • Dave62 (9/22/2010)


    I think the proper way to "rollback" a backup is to do a restore. 😉

    No, because that will bring the database back to a previous state. The way to rollback the backup would be to delete the file that was created.

  • cengland0 (9/22/2010)


    Dave62 (9/22/2010)


    I think the proper way to "rollback" a backup is to do a restore. 😉

    No, because that will bring the database back to a previous state. The way to rollback the backup would be to delete the file that was created.

    This may be one of those "it depends" things. In my way of thinking, when you rollback a transaction, returning it to the previous state (before the transaction began) is the desired outcome. So restoring the database after a backup is like rolling back a transaction. They both return the database to the state prior to the respective action.

    I see what you are saying though because if the database is live a restore would lose all transactions from all users that occurred after the backup.

    But if the database was in single-user mode during a maintenance window or something than the effect of a restore is the same as rolling back a transaction. And this is one situation I can think of where a DBA may want to "rollback" a backup. Something went wrong during maintenance and he or she wants to start over. But since you can't rollback a backup the next best option is to restore. In this case, trying to rollback by deleting the backup file would be disastrous for the DBA.

  • Dave62 (9/22/2010)


    cengland0 (9/22/2010)


    Dave62 (9/22/2010)


    I think the proper way to "rollback" a backup is to do a restore. 😉

    No, because that will bring the database back to a previous state. The way to rollback the backup would be to delete the file that was created.

    This may be one of those "it depends" things. In my way of thinking, when you rollback a transaction, returning it to the previous state (before the transaction began) is the desired outcome. So restoring the database after a backup is like rolling back a transaction. They both return the database to the state prior to the respective action.

    Not quite. Rolling back a transaction does NOT restore a database to the state it was in before the transaction began. It ONLY restores those items affected by the transaction --other data changes (e.g, by other users) are not rolled back. In this case, the items related to a backup are the backup file itself, and the metadata stored about the backup by SQL server. So "rolling back" a backup would be deleting the backup file and the metadata but leaving any changes to the database intact.

  • Carlo Romagnano (9/22/2010)


    Some operations have no sense inside a transaction. I surprise to see so many wrong answers.

    For me, it came down to a guess between would it just do the backup anyway or would it tell you that what you are doing does not make sense?

Viewing 15 posts - 1 through 15 (of 23 total)

You must be logged in to reply to this topic. Login to reply