/* * Generate a valid connect string and the backup command we should execute * in the seperate database controling thread. */ static inline void perform_ado_backup(bpContext *ctx) { plugin_ctx *p_ctx = (plugin_ctx *)ctx->pContext; POOL_MEM ado_connect_string(PM_NAME), ado_query(PM_NAME); POOLMEM *vdsname; /* * If no explicit instance name given usedthe DEFAULT_INSTANCE name. */ if (!p_ctx->instance) { p_ctx->instance = bstrdup(DEFAULT_INSTANCE); } set_ado_connect_string(ctx); vdsname = get_pool_memory(PM_NAME); wchar_2_UTF8(&vdsname, p_ctx->vdsname); switch (p_ctx->backup_level) { case L_INCREMENTAL: Mmsg(ado_query, "BACKUP LOG %s TO VIRTUAL_DEVICE='%s' WITH BLOCKSIZE=%d, BUFFERCOUNT=%d, MAXTRANSFERSIZE=%d", p_ctx->database, vdsname, DEFAULT_BLOCKSIZE, DEFAULT_BUFFERS, DEFAULT_BLOCKSIZE); break; case L_DIFFERENTIAL: Mmsg(ado_query, "BACKUP DATABASE %s TO VIRTUAL_DEVICE='%s' WITH DIFFERENTIAL, BLOCKSIZE=%d, BUFFERCOUNT=%d, MAXTRANSFERSIZE=%d", p_ctx->database, vdsname, DEFAULT_BLOCKSIZE, DEFAULT_BUFFERS, DEFAULT_BLOCKSIZE); break; default: Mmsg(ado_query, "BACKUP DATABASE %s TO VIRTUAL_DEVICE='%s' WITH BLOCKSIZE=%d, BUFFERCOUNT=%d, MAXTRANSFERSIZE=%d", p_ctx->database, vdsname, DEFAULT_BLOCKSIZE, DEFAULT_BUFFERS, DEFAULT_BLOCKSIZE); break; } Dmsg(ctx, dbglvl, "perform_ado_backup: ADO Query '%s'\n", ado_query.c_str()); p_ctx->ado_query = bstrdup(ado_query.c_str()); free_pool_memory(vdsname); }
/* * Generate a valid connect string and the restore command we should execute * in the seperate database controling thread. */ static inline void perform_ado_restore(bpContext *ctx) { POOL_MEM ado_query(PM_NAME), temp(PM_NAME); char vdsname[VDS_NAME_LENGTH + 1]; plugin_ctx *p_ctx = (plugin_ctx *)ctx->pContext; /* * If no explicit instance name given use the DEFAULT_INSTANCE name. */ if (!p_ctx->instance) { p_ctx->instance = bstrdup(DEFAULT_INSTANCE); } set_ado_connect_string(ctx); sprintf_s(vdsname, sizeof(vdsname), "%S", p_ctx->vdsname); switch (p_ctx->backup_level) { case L_INCREMENTAL: Mmsg(ado_query, "RESTORE LOG %s FROM VIRTUAL_DEVICE='%s' WITH BLOCKSIZE=%d, BUFFERCOUNT=%d, MAXTRANSFERSIZE=%d, %s", p_ctx->database, vdsname, DEFAULT_BLOCKSIZE, DEFAULT_BUFFERS, DEFAULT_BLOCKSIZE, p_ctx->DoNoRecovery ? "NORECOVERY" : "RECOVERY"); break; default: Mmsg(ado_query, "RESTORE DATABASE %s FROM VIRTUAL_DEVICE='%s' WITH BLOCKSIZE=%d, BUFFERCOUNT=%d, MAXTRANSFERSIZE=%d, %s", p_ctx->database, vdsname, DEFAULT_BLOCKSIZE, DEFAULT_BUFFERS, DEFAULT_BLOCKSIZE, p_ctx->DoNoRecovery ? "NORECOVERY" : "RECOVERY"); break; } /* * See if we need to insert any stopbeforemark arguments. */ if (p_ctx->stopbeforemark) { Mmsg(temp, ", STOPBEFOREMARK = '%s'", p_ctx->stopbeforemark); pm_strcat(ado_query, temp.c_str()); } /* * See if we need to insert any stopatmark arguments. */ if (p_ctx->stopatmark) { Mmsg(temp, ", STOPATMARK = '%s'", p_ctx->stopatmark); pm_strcat(ado_query, temp.c_str()); } /* * See if we need to insert any stopat arguments. */ if (p_ctx->stopat) { Mmsg(temp, ", STOPAT = '%s'", p_ctx->stopat); pm_strcat(ado_query, temp.c_str()); } /* * See if we need to insert the REPLACE option. */ if (p_ctx->ForceReplace) { pm_strcat(ado_query, ", REPLACE"); } Dmsg(ctx, dbglvl, "perform_ado_restore: ADO Query '%s'\n", ado_query.c_str()); p_ctx->ado_query = bstrdup(ado_query.c_str()); }