<div class="content" name="Backup" uuid="94e71123-2b82-4d36-ad7c-a1fa030d9e52"><p>The Backup method backs up the <a href="1243ba70-74ca-44f9-be0b-dfd6697010b4#gt_086b13f2-2715-4000-a16c-6acc3d59cc19" data-linktype="relative-path">metabase</a>.</p><dl>
<dd>
<div><pre> HRESULT Backup(
   [unique, in, string] LPCWSTR pszMDBackupName,
   [in] DWORD dwMDVersion,
   [in] DWORD dwMDFlags
 );
</pre></div>
</dd></dl><p><b>pszMDBackupName: </b>A string of up to 100 Unicode
characters that names the backup.</p><p><b>dwMDVersion: </b>An integer value specifying the
version number to be used for the backup.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Value</p>
   </th>
   <th>
   <p>Meaning</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>MD_BACKUP_HIGHEST_VERSION 0xFFFFFFFE</td>
  <td>Overwrite the highest existing backup version with the specified backup name.</td>
 </tr><tr>
  <td>MD_BACKUP_NEXT_VERSION 0xFFFFFFFF</td>
  <td>Use the next backup version number available with the specified backup name.</td>
 </tr></tbody></table>
</dd></dl><p><b>dwMDFlags: </b>An integer value containing the bit
flags describing the type of backup operation to be performed. The flags can be
one or more of the following values.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Value</p>
   </th>
   <th>
   <p>Meaning</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>MD_BACKUP_FORCE_BACKUP 0x00000004</td>
  <td>Force the backup even if the SaveData operation specified by MD_BACKUP_SAVE_FIRST fails.</td>
 </tr><tr>
  <td>MD_BACKUP_OVERWRITE 0x00000001</td>
  <td>Back up even if a backup of the same name and version exists, overwriting it if necessary.</td>
 </tr><tr>
  <td>MD_BACKUP_SAVE_FIRST 0x00000002</td>
  <td>Perform a SaveData operation before the backup.</td>
 </tr></tbody></table>
</dd></dl><p><b>Return Values: </b>A signed 32-bit value that
indicates return status. If the method returns a negative value, it failed. If
the 12-bit facility code (bits 16–27) is set to 0x007, the value contains a
Win32 error code in the lower 16 bits. Zero or positive values indicate success,
with the lower 16 bits in positive nonzero values containing warnings or flags
defined in the method implementation. For more information about Win32 error
codes and <a href="../ms-dtyp/a9046ed2-bfb2-4d56-a719-2824afce59ac" data-linktype="relative-path">HRESULT</a>
values, see <a href="../ms-erref/1bc92ddf-b79e-413c-bbaa-99a5281a6c90" data-linktype="relative-path">[MS-ERREF]</a>.</p><dl>
<dd>
<table><thead>
  <tr>
   <th>
   <p>Return value/code</p>
   </th>
   <th>
   <p>Description</p>
   </th>
  </tr>
 </thead><tbody><tr>
  <td>0x00000000 S_OK</td>
  <td>The call was successful.</td>
 </tr><tr>
  <td>0x80070057 E_INVALIDARG</td>
  <td>One or more arguments are invalid.</td>
 </tr><tr>
  <td>0x000CC809 MD_WARNING_SAVE FAILED</td>
  <td>The metadata save prior to backup failed. The previous version of the data was backed up.</td>
 </tr><tr>
  <td>0x80070008 ERROR_NOT_ENOUGH_MEMORY</td>
  <td>There is not enough memory to complete the operation.</td>
 </tr></tbody></table>
</dd></dl><p>The <a href="1243ba70-74ca-44f9-be0b-dfd6697010b4#gt_e127848e-c66d-427d-b3aa-9f904fa4ada7" data-linktype="relative-path">opnum</a>
field value for this method is 28.</p><p>The location string can be up to 100 Unicode characters in
length. Multiple metabase backups can be stored with the same name.</p><p>When processing this call, the server MUST do the following:</p><ul><li><p><span><span> 
</span></span>Check the <i>pszMDBackupName</i> parameter. If the length of the
string is 100 characters or more, or if it contains any characters in the
following set (&#39;/&#39;, &#39;\&#39;, &#39;*&#39;, &#39;.&#39;, &#39;?&#39;, &#39;&#34;&#39;, &#39;&amp;&#39;, &#39;!&#39;, &#39;@&#39;, &#39;#&#39;, &#39;$&#39;,
&#39;%&#39;, &#39;^&#39;, &#39;(&#39;, &#39;)&#39;, &#39;=&#39;, &#39;+&#39;, &#39;|&#39;, &#39;`&#39;, &#39;~&#39;) return E_INVALIDARG.</p>
</li><li><p><span><span> 
</span></span>Check the version parameter. If it is greater than the maximum
allowed version number and is not either MD_BACKUP_HIGHEST_VERSION or
MD_BACKUP_NEXT_VERSION, return E_INVALIDARG.</p>
</li><li><p><span><span> 
</span></span>If the parameter flags have the bit MD_BACKUP_SAVE_FIRST set,
flush the in-memory configuration data first. If this operation fails, check
the MD_BACKUP_FORCE_BACKUP bit. If this bit is not set, return an error.
Otherwise, continue the operation. If no subsequent error occurs, return MD_WARNING_SAVE_FAILED.</p>
</li><li><p><span><span> 
</span></span>Check the MD_BACKUP_OVERWRITE bit. If it is not set, check if a
backup with the target version exists. If it is TRUE, return an error,
otherwise overwrite the existing backup.</p>
</li><li><p><span><span> 
</span></span>If the value of the <i>pszMDBackupName</i> parameter is an empty
string, the server uses a default name for the backup.</p>
</li><li><p><span><span> 
</span></span>The server saves the persisted data using the backup name and the
version number as a key so that the data can be restored later.</p>
</li></ul></div>