From: Thorsten E. <tho...@ma...> - 2007-03-09 09:36:01
|
Dear Fan, let's sort some things out at the first step: 1. you're right: bacula currently only prepares vss backups on a "per volume" mode. it does not care for, let's say sql .log/.mdf files. But vss will automatically use the sqlserver-vsswrite to create a consistent state for the shadow copy, if the volume to be backed up includes a .log/.mdf. I think, this you figured out already yourself ;-) 2. backupread/write only cares for all ntfs-streams a file may contain. This stream-system is similar to the fork files apple supports. *normally* a ntfs file only contains 2 streams: detailed security information and the plain content of the file. So backupread/write is a completely independent thing in relation to vss. 3. the current restore process works without vss what is fine, because in this (in comparison to backups rare) case, you can stop the software, so that it leaves it fingers away from the file you want to replace. the you don't need vss. 4. of course there are many scenarios, where vss restore *really* make sense. in your case and when working with exchange for example! OKay, so now you know why I didn't care for the vss restore but welcome your work! I personally did closely follow the examples from the vss sdk. Then I stripped some things, I didn't need, fighted with com and tested multiple backupcalls until they worked.... Unfortunately I right now don't have the time to dig into this completely together with you, but it may be that the "cocreatesecurity" or "init com" and so on may be your problems. Please try the "restore" code from the vss sdk examples. You'll *really* need it! did you already download them from m$? 80004001 could mean 'not implemented'. If this is the case, again look into the examples. one has to work differently on xp and windows 2003. The latter one supports more... Was this of help for you? best, thorsten Thorsten Engel > > Thanks Kern! > > (I come from China, I am 23, my english may not well :) ) Well, my Chinese consists of reading about 3 or 4 characters :-) I think we can figure out what you mean. I think I will let Thorsten answer, since I don't know much about vss. I will make a couple of notes below ... > > I just modified the part of vss code(/src/win32/filed/) and a little job.c > (/src/filed/). > > In a backup task flow, I did (in ./src/win32/filed/vss_generic.cpp): > 1). After BOOL VSSClientGeneric::Initialize(DWORD dwContext, BOOL > bDuringRestore) function, I add a function and call it after Initialize(). > The function do add a component to Backup Components Document option. The > component is a database message in sqlwriter Metadata Document. (I can pass > the GetWriterMetadata and other functions to get the parameters which the > AddComponent() needs. and It is ok.) > My sqlwriter Metadata Document content is(I added some blank line for > readable): ---------------------------------------------- > <WRITER_METADATA xmlns="x-schema:#VssWriterMetadataInfo" version="1.0"> > > <IDENTIFICATION writerId="a65faa63-5ea8-4ebc-9dbd-a0c4db26912a" > instanceId="bf40ba33-7ae4-4fa2-bae6-3dd148ba396f" > friendlyName="SqlServerWriter" usage="USER_DATA" > dataSource="TRANSACTION_DB"/> > > <RESTORE_METHOD method="RESTORE_IF_CAN_BE_REPLACED" writerRestore="always" > rebootRequired="no"/> > > <BACKUP_LOCATIONS> > > <FILE_GROUP logicalPath="FANXIAOGANG\SQLEXPRESS" componentName="master" > restoreMetadata="no" notifyOnBackupComplete="yes" selectable="yes"> > <FILE_LIST path="C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA" > filespec="master.mdf"/> > <FILE_LIST path="C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA" > filespec="mastlog.ldf"/> > </FILE_GROUP> > > <FILE_GROUP logicalPath="FANXIAOGANG\SQLEXPRESS" componentName="model" > restoreMetadata="no" notifyOnBackupComplete="yes" selectable="yes"> > <FILE_LIST path="C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA" > filespec="model.mdf"/> > <FILE_LIST path="C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA" > filespec="modellog.ldf"/> > </FILE_GROUP> > > <FILE_GROUP logicalPath="FANXIAOGANG\SQLEXPRESS" componentName="msdb" > restoreMetadata="no" notifyOnBackupComplete="yes" selectable="yes"> > <FILE_LIST path="C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA" > filespec="MSDBData.mdf"/> > <FILE_LIST path="C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA" > filespec="MSDBLog.ldf"/> > </FILE_GROUP> > > <FILE_GROUP logicalPath="FANXIAOGANG\SQLEXPRESS" componentName="first" > restoreMetadata="no" notifyOnBackupComplete="yes" selectable="yes"> > <FILE_LIST path="C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data" > filespec="first.mdf"/> > <FILE_LIST path="C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data" > filespec="first_log.ldf"/> > <FILE_LIST path="D:\sqlData" filespec="seconday.ndf"/> > </FILE_GROUP> > > <FILE_GROUP logicalPath="FANXIAOGANG\SQLEXPRESS" componentName="second" > restoreMetadata="no" notifyOnBackupComplete="yes" selectable="yes"> > <FILE_LIST path="C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA" > filespec="second.mdf"/> > <FILE_LIST path="C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA" > filespec="second_log.ldf"/> > </FILE_GROUP> > > </BACKUP_LOCATIONS> > </WRITER_METADATA> > ------------------------------------------------ > I just add the "second" database components message in the Backup > Components Document. Not any other option. > And after the backup finish, I saved the Backup Compoents doc and sqlwriter > Metadata doc.(After pVss->BackupComplete(&pAsync.p) completely in BOOL > VSSClientGeneric::CloseBackup() do the save work.) > > > > My Backup Components Document content is: > ------------------------------------------------ > <BACKUP_COMPONENTS xmlns="x-schema:#VssComponentMetadata" version="1.0" > bootableSystemStateBackup="yes" selectComponents="yes" backupType="full"> > > <WRITER_COMPONENTS instanceId="c4610868-5090-4af2-a0f7-9828e03c58fe" > writerId="a65faa63-5ea8-4ebc-9dbd-a0c4db26912a"> > <COMPONENT logicalPath="FANXIAOGANG\SQLEXPRESS" componentName="second" > componentType="database"/> > </WRITER_COMPONENTS> > > </BACKUP_COMPONENTS> > ------------------------------------------------ > Is the content right? It not include the restore method ? > > It can compile the bacula fd, and run it use enable_vss on, and can > completely a backup task no error. When Bacula does a backup, the data streams that Bacula writes are identical with and without VSS. With VSS, Bacula simply gets the file data from the snapshot (shadow copy) of the file rather than directly from the file using BackupRead(). During the restore, the data that was written during the backup is read, then simply written to disk using BackupWrite(). No VSS is needed. > > > 2). In the restore part, I added a new function in restore_cmd() which is > in job.c. The insert Positon is after "do_restore(jcr)". I just want to > test the vss restore now. The funtion main include : > IVssBackupComponents::InitializeForRestore, (can get the backup compoents > doc right) > IVssBackupComponents::GatherWriterMetadata, > IVssBackupComponents::SetSelectedForRestore, (can get the right parameters > right, and the sqlwriter running ok) > IVssBackupComponents::PreRestore, > (copy the file to the original position) > IVssBackupComponents::SetFileRestoreStatus, > IVssBackupComponents::PostRestore, > IVssBackupComponents::Release. As I said, I am not a VSS expert, maybe Thorsten can explain. However, if you have read special backup data that is not read with BackupRead(), then you will need to write it to a different Bacula stream (STREAM_....) . Then when doing a restore, when that special stream is encountered you will need to use whatever techniques VSS provides for giving it back to the application. > > It can compiled the bacula fd right. But when running a restore task, The > SetSelectedForRestore() return an error 80004001, and terminate. I suspect that you never write the data out to the Bacula Volume during the backup procedure. I suspect that VSS simply wrote the data somewhere to disk and you must then read and write that data to the Bacula volume. Thorsten can probably answer this better than I can. > I am desponding. What's wrong with me? Would you give me some advices? or > give me a vss restore simple code. The bacula not include the vss restore ? > I referenced the betest and vshadow examples which is in vss sdk, But no > idea. -------------------------------------------------------------- Hopefully the above will give you some ideas and that Thorsten can give you some more ideas ... > Thank you very much! > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share > your opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Bacula-devel mailing list > Bac...@li... > https://lists.sourceforge.net/lists/listinfo/bacula-devel |