Backup with setFormatMedia

  • Hi,

    I ran into problem when I set FormatMedia property to TRUE in backup object. if I do not set this property or set it to FALSE, the code runs fine.

    Here is the exerpt of the relevant code:

    g_pSQLBackup->SetDatabase (g_szDBName);

    g_pSQLBackup->SetTapes(g_szBkupRstrFileName);

    g_pSQLBackup->SetAction(SQLDMOBackup_Database);

    g_pSQLBackup->SetBackupSetName (g_szBkupSetName);

    g_pSQLBackup->SetFormatMedia (TRUE);

    // perform backup

    if FAILED(hr = g_pSQLBackup->SQLBackup (g_pSQLServer)) {

    printf("in C, Backup failed\n");

    } else {

    printf("in C, Backup is successful\n");

    }

    Please help me identify what's wrong with my code.

    Thanks

    Bill

  • Hi Bill,

    Sorry for the late reply, was out of the office for a few days. It'll be another day or two before I get a chance to look into it, don't have a machine at home right now that has SQL AND a tape drive!

    Andy

  • Hi, Andy,

    Glad to hear from you. Here is additional info:

    1) SQL server 7.0

    2) if I use SetInitialize(TRUE) instead of SetFormatMedia(TRUE), the code can also run without problem.

    3) if I use T-SQL to do backup, there is no problem with format or init option. But I may have to use DMO because of the event feature, such as nextMedia event I need to show to user via Java app.

    Bill

  • Cool - I'll try to experiment tonight if I can get everythign working at home so I have a tape to test with.

    Andy

  • Hey Bill,

    Think this is a record for slowest reply, sorry for the delay. Did some quick testing and found that if I do the following it works:

    .FormatMedia = True

    .Initialize = True

    .SkipTapeHeader = True

    There is some interaction between init and skip, take a look at Backup in BOL. A good way to get a better feel for whats going on is to do the following just before the call to the SQLBackup method:

    sql = .GenerateSQL

    Debug.Print sql

    That way you can see exactly what DMO is generating. See if that works. If not, we'll definitely try to do a faster turn around on the next question!

    Andy

  • Hi, Andy

    It Works! Your suggestions are very helpful.

    Thanks a lot

    Bill

  • Glad it helped!

    Andy

Viewing 7 posts - 1 through 6 (of 6 total)

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