Category: Blog

  • Speaking in 2017

    I’m done. No more trips (and no more time) to hit any events this year. As I wrote recently, I’m doing less in 2018, so this review might be quite short next year.

    In any case, I thought I’d look back at how speaking went in 2017. I have a speaking CV where I track all my events, so I can get the numbers easily from there. By the numbers, 2017 was:

    • 18 total events
    • 34 total talks
    • 15 unique talks
    • 5 SQL Saturdays (not a lot)
    • 5 virtual events (3 from Redgate)
    • 4 new events for me
    • 4 countries in which I delivered talks (1 new)

    Overall a long year for me. Those 18 events resulted in a lot of trips and about 80 nights in hotels. I had some work engagements as well, but most trips involved speaking somewhere.

    I am saddened that I didn’t present at any user groups this year, which is something that hasn’t happened in awhile. Hopefully I’ll do better next year at getting to a few user groups.

    One thing here is that I discounted some of the Redgate DevOps webinars that we do monthly. I probably did 5 or 6 of those, but I’m not really presenting in most of these, mostly hosting, so I left those out.

    Oh, and 1 Habitat for Humanity talk to add to this list Winking smile

  • Restoring a Copy Only Backup–#SQLNewBlogger

    Another post for me that is simple and hopefully serves as an example for people trying to get blogging as #SQLNewBloggers.

    There was a question posted recently at SQLServerCentral about whether a copy only backup could be restore with a transaction log backup from a database. I was positive this could, but decided I needed to repro and test for someone as there wasn’t a good BOL reference.

    The Tests

    Here’s what I did. First, I created a table in a database. I often do this and drop in messages to allow me to track the progress of backups and restores. This post follows my progress.

    The Backups

    Here’s my basic script:

    CREATE TABLE logger(msg VARCHAR(200), msgdate DATETIME DEFAULT GETDATE())
    
    INSERT logger (msg) SELECT 'pre full backup'

    Next, I made a backup and added a message.

    INSERT logger (msg) SELECT 'pre-log backup 1'
    BACKUP LOG nba TO disk = 'nba_1.trn'
    INSERT logger (msg) SELECT 'log backup 1 complete'

    Once this is done, I’m in a state that I expect. A normal full backup, a normal log backup, and some data to help me track where I am.

    Now let’s make a copy only backup.

    INSERT logger (msg) SELECT 'pre copy-only backup '
    BACKUP DATABASE nba TO DISK  = 'nba_copy.bak' WITH COPY_ONLY
    INSERT logger (msg) SELECT 'copy-only backup complete'

    This now means I have an open log sequence in the first log backup (post full backup) and a few log records since then. Some of these are inside the copy only backup.

    Now let’s add more data and make a new, regular, log backup.

    INSERT logger (msg) SELECT 'pre-log backup 2'
    BACKUP LOG nba TO disk = 'nba_2.trn'
    INSERT logger (msg) SELECT 'log backup 2 complete'

    It’s at this point that I have this sequence:

    • Full backup
    • Log backup
    • Copy-Only Full backup
    • Log backup

    The Restore

    What I want to test is can I restore the Copy-Only backup and a log backup? I think I can, so let’s do that. First, restore from the copy-only backup, using the MOVE option.

    USE [master]
    RESTORE DATABASE [NBA2] 
    FROM  DISK = N'D:\SQLServerBackup\MSSQL13.SQL2016\MSSQL\Backup\nba_copy.bak' 
    WITH  FILE = 1,  
          MOVE N'NBA' TO N'E:\SQLServer\MSSQL13.SQL2016\MSSQL\Data\NBA2.mdf',  
          MOVE N'NBA_log' TO N'E:\SQLServer\MSSQL13.SQL2016\MSSQL\Data\NBA2_log.ldf',  
          MOVE N'nba_mo_file1' TO N'E:\SQLServer\MSSQL13.SQL2016\MSSQL\Data\NBA2_mo',  
          MOVE N'nba_mo_file2' TO N'E:\SQLServer\MSSQL13.SQL2016\MSSQL\Data\NBA2_mo2'
    ,  NOUNLOAD,  STATS = 5
    , NORECOVERY

    Tip: Always use NORECOVERY

    Now let’s try to restore the log.

    RESTORE LOG NBA2 FROM DISK = 'nba_2.trn' WITH NORECOVERY
    
    RESTORE DATABASE nba2 WITH RECOVERY

    This works:

    2017-12-06 17_57_56-SQLQuery2.sql - (local)_SQL2016.master (PLATO_Steve (63))_ - Microsoft SQL Serve

    That should prove things. Let’s check the logger table.

    2017-12-06 18_00_45-SQLQuery2.sql - (local)_SQL2016.NBA2 (PLATO_Steve (63))_ - Microsoft SQL Server

    That’s what we expect. The final message after log backup2 wasn’t captured in our backup files.

    Copy Only Backups

    What is a copy only backup? If we check the Copy-Only Backups page, we find that this is a regular backup in and of-itself, but it has the restriction that it cannot be used with differential backups. This also doesn’t change the differential bitmap, so that any differentials that are made ignore this backup and go back to include data changed since the last “normal” full backup.

    SQLNewBlogger

    Understanding backup and recovery is critical for a data professional. I’d say this is the most important skill, and it’s always worth writing about. Spend a few minutes reviewing scenarios and creating some posts like this to show you understand how the system works.

  • Back to Work

    It seems like it’s been a long time since I wrote any SQL code or did any work. Two weeks ago I was in the UK for SQL in the City, which was a lot of prep work when I arrived with little actual work on the site or with customers. The few days after the broadcast involved meetings and getting ready for the annual Redgate Christmas Party and company awards. I was hosting, so I had to practice and prep for the night. It went well, with everyone indulging me with an on-stage selfie:

    IMG_3405

    Last week was another trip, my final of the year, but a good one. I was luck to spend a week unwired with my wife in Athens. We enjoyed the time, and got to relax without commitments, something that I don’t do often. We didn’t do much except enjoy the time and sights.

    Now it’s back to work after Christmas. I’m ready to go, though that might have something to do with my body still being on GMT time, but in any case, I’m ready to fire up SSMS and do some work.

    Merry Christmas, Happy Holidays, and Happy New Year to everyone.

  • Holiday

    I’m off on vacation this week, enjoying Athens with my wife. I’ll be unlikely to respond to communications during this time.

    Have a great week and I’ll be back after Christmas.