<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
    <channel>
        <title>CUBRID Backup &amp; Restore – Part I (Backup)</title>
        <link>http://www.cubrid.org/?mid=cubrid_backup_restore</link>
        <description>CUBRID Backup &amp; Restore – Part I (Backup)</description>
        <language>en</language>
        <pubDate>Tue, 08 Feb 2011 08:00:46 -0800</pubDate>
        <lastBuildDate>Fri, 08 Apr 2011 11:10:58 -0800</lastBuildDate>
        <generator>XpressEngine 1.4.4.1</generator>
                        										        <item>
            <title>CUBRID Backup &amp; Restore – Part I (Backup)</title>
            <dc:creator>admin</dc:creator>
            <link>http://www.cubrid.org/cubrid_backup_restore</link>
            <guid isPermaLink="true">http://www.cubrid.org/cubrid_backup_restore</guid>
                                    <description><![CDATA[<h1>CUBRID Backup &amp; Restore – Part I (Backup)</h1>

<div class="category"><a href="/tutorials">⇐Tutorials</a><a href="/cubrid_backup_restore_2" class="right">Part II (Restore)⇒</a><br /><br />
<a class="pdf right" href="/files/docs/tutorials/cubrid/CUBRID%20Backup%20&amp;%20Restore%20-%20Part%20I%20(Backup).pdf">Download this document in PDF</a>
</div>

<div class="contents-table"></div>

<p>The scope of this tutorial is to present the database backup &amp; restore capabilities in CUBRID. The tutorial is split into two parts:</p>
<ul>
	<li>Part I: Backup</li>
	<li>Part II: Restore</li>
</ul>

<h2>Overview</h2>

<p>One of the main responsibilities of a CUBRID DBA is to perform regular backups of the databases, so that it can be restored successfully to a previous state in case of system failure.</p>

<p>A database backup is the procedure of storing:</p>
<ul>
<li><b>Database volumes</b></li>
<li><b>Control files</b></li>
<li><b>Log files</b></li>
</ul>

<p>... and it is executed by using the <b>cubrid backupdb</b> utility or the <a href="/cubrid_manager">CUBRID Manager</a>.</p>

<h2>CUBRID backupdb utility</h2>

<p><b>backupdb</b> is a CUBRID utility used for creating database backups, which is able to perform either:</p>

<ul>
<li>Online Backup</li>
<li>Offline Backup</li>
<li>Compressed Backup</li>
<li>Parallel Backup</li>
</ul>

<p class="important">The <b>backupdb</b> utility can only be executed by a user who has the backup authorization (e.g. <b>dba</b>).</p>

<p>Syntax:</p>

<div class="code">
<div editor_component="code_highlighter" code_type="bash" file_path="" description="" first_line="1" collapse="false" nogutter="false" nocontrols="false">
cubrid backupdb [ options ] database_name
[ options ]
-D | -r | -l | -o | -S | -C | -t | -z | -e |
--destination-path | --remove-archive | --level | --output-file | --SA-mode | --CS-mode | --thread-count | --compress | --except-active-log | --no-check
</div>
</div>

<p>The following table shows options that can be used with backupdb utility. Remember - these options are case sensitive:</p>

<table class="blackcap rowbg">
<thead>
	<tr>
		<td width="150">Option</td>
		<td>Description</td>
	</tr>
</thead>
<tbody>
<tr>
<td>-D<br />--destination-path</td>
<td>Specifies the directory path name (or device name) where backup volumes are to be created.<br />
The default value is the location of <b>log_path</b> parameter specified in the databases location file (<b>databases.txt</b>).</td>
</tr>
<tr>
<td>-r<br />--remove-archive</td>
<td>Removes unnecessary archive logs after the backup is complete.</td>
</tr>
<tr>
<td>-l<br />--level</td>
<td>Configures the backup level to 0, 1 or 2 – we will present later the options available for this parameter.
The default value is a <b>full backup</b> (0).</td>
</tr>
<tr>
<td>-o<br />--output-file</td>
<td>Specifies the name of the file where operation information is to be saved.</td>
</tr>
<tr>
<td>-S<br />--SA-mode</td>
<td>Performs a backup in standalone mode.
The default value is the one specified by the system parameter <b>CUBRID_MODE</b>.</td>
</tr>
<tr>
<td>-C<br />--CS-mode</td>
<td>Performs a backup in client/server mode.
The default value is the one specified by the system parameter <b>CUBRID_MODE</b>.</td>
</tr>
<tr>
<td>-t<br />--thread-count</td>
<td>Specifies the maximum number of threads allowed for a parallel backup.
The default value is the number of CPUs in the system.</td>
</tr>
<tr>
<td>-z<br />--compress</td>
<td>Performs a compressed backup.</td>
</tr>
<tr>
<td>-e<br />--except-active-log</td>
<td>Configures that active log volumes are not included in the backup.</td>
</tr>
<tr>
<td>--no-check</td>
<td>Does not perform a consistency check on a database before making a backup.</td>
</tr>
<tr>
<td>-sp<br />--safe-page-id</td>
<td>This option is used with the <b>-r</b> option where replication is configured. The <b>-r</b> option must be used with the <b>-sp</b> option so that unnecessary archive logs can be cleared, while the necessary information for replication is stored.</td>
</tr>
</tbody>
</table>

<h2 id="">Usage examples</h2>

<p>In this section we will present various examples of using the <b>backupdb</b> utility.</p>

<h3>Specifying where to sore the backup files</h3>

<p>The following is an example that uses the <b>-D</b> option to store backup files in the specified folder. The backup file folder must be specified before performing this job.</p> 

<p class="important"><b>Note:</b> If the <b>-D</b> option is not specified, backup files are stored in the folder specified in the <b>databases.txt</b> file.</p>

<div class="code">
<div editor_component="code_highlighter" code_type="plain" file_path="" description="" first_line="1" collapse="false" nogutter="false" nocontrols="false">
&gt;cubrid backupdb -D /home/cubrid/backup demodb
</div>
</div>

<p>The following example stores backup files in the current directory by using the <b>-D</b> option. If you enter a period (.) following the <b>-D</b> option as an argument, the current directory is specified.</p>

<div class="code">
<div editor_component="code_highlighter" code_type="plain" file_path="" description="" first_line="1" collapse="false" nogutter="false" nocontrols="false">
&gt;cubrid backupdb -D . demodb
</div>
</div>

<h3>Removing archive logs after a backup (-r or --remove-archive)</h3>

<p>If the database parameter <b>media_failure_support</b> is set to <b>1</b>, when the active logs are full, they are written to a new archive log file. If a backup is performed in such a situation and backup volumes are created, backup logs created before the backup will not be used in subsequent backups. The <b>-r</b> option is used to remove archive log files that will not be used any more in subsequent backups after the current one is complete.</p>

<div class="code">
<div editor_component="code_highlighter" code_type="plain" file_path="" description="" first_line="1" collapse="false" nogutter="false" nocontrols="false">
&gt;cubrid backupdb -r demodb
</div>
</div>

<p class="important">It is recommended that the <b>-r</b> option only be used when a full backup is performed.</p>

<h3>Storing page information necessary for replication (-sp or --safe-page-id)</h3>

<p>The <b>-sp</b> option is mandatory when the <b>-r</b> option is used and replication is configured. Only archive logs that have smaller IDs than the ID of the latest log page are safely cleared and not the latest ID log. The <b>-sp</b> option makes the <b>-r</b> option limitedly performed, in order to reserve the log page information necessary for replication.</p>

<p>Also, you should specify the <b>repl_safe_page</b> database name as an argument.</p>

<div class="code">
<div editor_component="code_highlighter" code_type="plain" file_path="" description="" first_line="1" collapse="false" nogutter="false" nocontrols="false">
&gt;cubrid backupdb -r -sp 'repl_safe_page demodb' demodb
</div>
</div>

<h3>Performing a backup with the backup level specified (-l or --level)</h3>

<p>The following example performs an incremental backup of the level specified by using the <b>-l</b> option. If the <b>-l</b> option is not specified, a full backup is performed.</p>

<div class="code">
<div editor_component="code_highlighter" code_type="plain" file_path="" description="" first_line="1" collapse="false" nogutter="false" nocontrols="false">
&gt;cubrid backupdb -l 1 demodb
</div>
</div>

<div class="important">
<p>CUBRID supports the following types of backups:</p>
<ul>
<li>Full backup (backup level 0). Backup level 0 is a full backup that includes all database pages.</li>
<li>First incremental backup (backup level 1). Backup level 1 is an incremental backup that only saves changes since the level 0 full backup, and is called a "first incremental backup."</li>
<li>Second incremental backup (backup level 2). Backup level 2 is an incremental backup that only saves data that have changed since the first incremental backup, and is called a "second incremental backup."</li>
</ul>
</div>

<h3>Saving backup progress information in the specified file (-o or --output-file)</h3>

<p>The following example writes the progress of the database backup to the <b>info_backup</b> file by using the <b>-o</b> option.</p>

<div class="code">
<div editor_component="code_highlighter" code_type="plain" file_path="" description="" first_line="1" collapse="false" nogutter="false" nocontrols="false">
&gt;cubrid backupdb -o info_backup demodb
</div>
</div>

<p>The following is an example the <b>info_backup</b> file. You can see the information about the number of threads, compression method, backup start time, the number of permanent volumes, backup progress and backup end time:</p>

<div class="code">
<div editor_component="code_highlighter" code_type="plain" file_path="" description="" first_line="1" collapse="false" nogutter="false" nocontrols="false">
[ Database(demodb) Full Backup start ]
- num-threads: 1
- compression method: NONE
- backup start time: Mon Jul 21 16:51:51 2008
- number of permanent volumes: 1
- backup progress status
-----------------------------------------------------------------------------
 volume name  | # of pages | backup progress status  | done
-----------------------------------------------------------------------------
 demodb_vinf  |  1 | ######################### | done
 demodb   |  25000 | ######################### | done
 demodb_lginf   |  1 | ######################### | done
 demodb_lgat  |  25000 | ######################### | done
-----------------------------------------------------------------------------
# backup end time: Mon Jul 21 16:51:53 2008
[Database(demodb) Full Backup end]
</div>
</div>

<h3>Performing a backup in standalone mode (-S or --SA-mode)</h3>

<div class="code">
<div editor_component="code_highlighter" code_type="plain" file_path="" description="" first_line="1" collapse="false" nogutter="false" nocontrols="false">
&gt;cubrid backupdb -S demodb
</div>
</div>

<h3>Performing a backup in client/server mode (-C or --CS-mode)</h3>

<div class="code">
<div editor_component="code_highlighter" code_type="plain" file_path="" description="" first_line="1" collapse="false" nogutter="false" nocontrols="false">
&gt;cubrid backupdb -C demodb
</div>
</div>

<h3>Parallel backup (-t or --thread-count)</h3>

<p>The following example performs a parallel backup, with the number of threads specified by using the <b>-t</b> option. If the argument of the <b>-t</b> option is not specified, a parallel backup is performed by automatically assigning as many threads as CPUs in the system.</p>

<div class="code">
<div editor_component="code_highlighter" code_type="plain" file_path="" description="" first_line="1" collapse="false" nogutter="false" nocontrols="false">
&gt;cubrid backupdb -t 4 demodb
</div>
</div>

<h3>Compressed backup (-z or --compress)</h3>

<p>The following example compresses the database and stores it in the backup file, by using the <b>-z</b> option.</p>
<p class="important">Note: The size of the backup file and the time required for backup can be reduced by using the <b>-z</b> option.</p>

<div class="code">
<div editor_component="code_highlighter" code_type="plain" file_path="" description="" first_line="1" collapse="false" nogutter="false" nocontrols="false">
&gt;cubrid backupdb -z demodb
</div>
</div>

<h3 id="">Enabling to exclude active log volumes (-e or --except-active-log)</h3>

<p>The following example performs a backup, excluding active logs of the database by using the <b>-e</b> option. You can reduce the time required for backup by using the <b>-e</b> option. However, extra caution is required because active logs needed for completing a restore to the state of a certain point from the backup point are not included in the backup file, which may lead to an unsuccessful restore.</p>

<div class="code">
<div editor_component="code_highlighter" code_type="plain" file_path="" description="" first_line="1" collapse="false" nogutter="false" nocontrols="false">
&gt;cubrid backupdb -e demodb
</div>
</div>

<h3 id="">Disabling a database consistency check (--no-check)</h3>

<p>The following example performs a backup without checking the consistency of the database.</p>

<div class="code">
<div editor_component="code_highlighter" code_type="plain" file_path="" description="" first_line="1" collapse="false" nogutter="false" nocontrols="false">
&gt;cubrid backupdb --no-check demodb
</div>
</div>

<h2 id="">Backup database using CUBRID Manager Client</h2>

<p>To backup a database backup from the CUBRID Manager client, perform one of the following after login to the database:</p>

<ul>
<li>Click Backup Database from the toolbar.</li>
<li>Right-click the database and then select Backup Database.</li>
<li>Select Action -&gt; Backup Database in the menu.</li>
</ul>

<p class="important">The backup operation can be performed even when the database server is running.</p>

<p>The following dialog is displayed, where you specify the backup options:</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/645/004/database-backup-options.png" alt="database-backup-options.png" width="708" height="415" editor_component="image_link"/></p>

<table class="blackcap rowbg">
<thead>
<tr>
<td width="199">Option</td>
<td width="417">Description</td>
</tr>
</thead>
<tbody>
<tr>
<th>Database name</th>
<td>The name of the database to backup.</td>
</tr>
<tr>
<th>Volume name</th>
<td>Specifies the name of the backup volume.</td>
</tr>
<tr>
<th><b>Backup</b> level</th>
<td>Specifies the backup level.<br />If there is a backup volume displayed as Level 0, the administrator can choose only Level 0 or Level 1. If there are no previously performed backups, the administrator can choose only Level 0.</td>
</tr>
<tr>
<th><b>Backup</b> directory</th>
<td>Specifies the directory where backup files are to be saved.</td>
</tr>
<tr>
<th>Checking consistency of the database</th>
<td>Checks consistency of the database to backup before the backup process. <b>It is recommended to select this option.</b></td>
</tr>
<tr>
<th>Delete unnecessary log-archives</th>
<td>Deletes unnecessary archive log files while restoring a database. Note that archive log files might be required if database restore does not go well due to backup file errors. When this option is selected while the database is set to the master server in the replication environment, the Maintain replication log option is checked automatically.</td>
</tr>
<tr>
<th>Number thread</th>
<td>Specifies the number of threads to be used concurrently during the database backup. <b>It is recommended to set the maximum number of threads to be the same as the number of CPUs</b>. The default value is 0, in which case the number of threads is automatically determined.</td>
</tr>
<tr>
<th>Compress <b>backup</b> volumes</th>
<td>Compresses the database backup. <b>It is recommended to select this option. </b></td>
</tr>
</tbody>
</table>

<p>If a backup has been executed for the database, you can check the backup history from the <b>Backup History Information</b> tab. You can see information such as the backup level, last backup date, size of the backup file, backup file path as well as free space of the disk where the current database volume exists:</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/645/004/database-backup-history-info.png" alt="database-backup-history-info.png" width="601" height="286" editor_component="image_link"/></p>

<h2 id="">Backup Automation from CUBRID Manager Client</h2>

<p>When you login to the database, you have access to <b>Backup plan</b>, under <b>Job automation</b> in the left navigation tree. The <b>Add Backup Plan</b> and <b>Auto Backup Logs</b> menus are available when you right-click on <b>Backup plan</b>:</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/645/004/add-backup-plan.png" alt="add-backup-plan.png" width="396" height="264" editor_component="image_link"/></p>

<p>If you want to activate a backup periodically with the CUBRID Manager client, you need to configure the values, using <b>Add Backup Plan</b>. The <b>DBA</b> can configure the backup automation while the Manager server is running - it is not affected by whether the database is running or not.</p>

<p class="important">A backup automation is executed only when the Manager server is running.</p>

<h3 id="">Add Backup Plan</h3>

<p><img src="http://www.cubrid.org/files/attach/images/49/645/004/add-backup-plan-window.png" alt="add-backup-plan-window.png" width="509" height="544" editor_component="image_link"/></p>

<p>These are the options you can configure:</p>

<table class="blackcap rowbg">
<thead>
<tr>
<td width="200">Option</td>
<td>Description</td>
</tr>
</thead>
<tbody>
<tr>
<th><b>Backup</b> ID</th>
<td>The name of the backup job. The backup ID must be unique in the database because multiple backup plans may exist in the same database.</td>
</tr>
<tr>
<th><b>Backup</b> level</th>
<td>You can choose from 0, 1, and 2.</td>
</tr>
<tr>
<th><b>Backup</b> path</th>
<td>Specifies the folder of the backup volume.</td>
</tr>
<tr>
<th>Period type</th>
<td>You can select a backup period from options of Monthly, Weekly, Daily and a specific day.</td>
</tr>
<tr>
<th>Period detail</th>
<td>You can set details for the period type you selected.</td>
</tr>
<tr>
<th><b>Backup</b> hour</th>
<td>Enter the time when the automated backup is to be executed. You must enter the time in hour and minute.</td>
</tr>
<tr>
<th>Store old <b>backup</b> file</th>
<td>This option saves the current original backup volume file of the database in <b>database_directory/backupold</b> directory.</td>
</tr>
<tr>
<th>Delete archive volumes</th>
<td>An option that deletes archive log volumes after backup. When this option is selected while the database is set to master server in the replication environment, volumes do not affect the replication will be deleted automatically.</td>
</tr>
<tr>
<th>Update statistics information</th>
<td>Updates statistics information after backup.</td>
</tr>
<tr>
<th>Checking database consistency</th>
<td>Checks database consistency during backup.</td>
</tr>
<tr>
<th>Use compress</th>
<td>Uses compression during backup.</td>
</tr>
<tr>
<th>Number thread</th>
<td>Specifies the number of threads to be used concurrently during backup.</td>
</tr>
<tr>
<th>Online <b>backup</b></th>
<td>Automated backup is executed only when the database is running. If the database is stopped, only error logs are recorded without backing up the database.</td>
</tr>
<tr>
<th>Offline <b>backup</b></th>
<td>Automated backup is executed only when the database stopped running. Forces the database to shut down if it is currently running, performs an automated backup, and then restarts the database.</td>
</tr>
</tbody>
</table>

<h3 id="">Auto Backup Log</h3>

<p>This menu provides information about the error logs created during backup automation execution:</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/645/004/auto-backup-logs.png" alt="auto-backup-logs.png" width="602" height="295" editor_component="image_link"/></p>

<h3 id="">Edit/Delete Backup Plan</h3>

<p>Right-click a desired backup automation in the left navigation tree and then select Edit Backup Plan, or Delete Backup Plan:</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/645/004/edit-delete-backup-plan.png" alt="edit-delete-backup-plan.png" width="390" height="110" editor_component="image_link"/></p>

<p>They are used for editing the backup automation jobs in the same way as for adding backup automation, or for deleting backup automation jobs.</p>

<h2 id="">Backup Strategy</h2>

<p>The followings must be considered before planning and executing a database backup:</p>
<ul>
<li><b>Selecting the data to be backed up</b></li>
<ul>
<li>Determine whether it is valid data worth being preserved. </li>
<li>Determine whether to back up the entire database or only part of it. </li>
<li>Check whether there are other files to be backed up along with the database. </li>
</ul>
<li><b>Choosing a backup method</b></li>
<ul>
<li>Choose the backup method from one of incremental and online backups. Also, specify whether to use compression backup, parallel backup, and mode. </li>
<li>Prepare backup tools and devices available. </li>
</ul>
<li><b>Determining backup time</b></li>
<ul>
<li>Identify the time when the least usage in the database occur. </li>
<li>Check the size of the archive logs. </li>
<li>Check the number of clients using the database to be backed up. </li>
</ul>
</ul>

<h3 id="">Example</h3>

<p>The following is an example of a suggested CUBRID backup strategy/plan:</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/645/004/backup-strategy.png" alt="backup-strategy.png" width="466" height="259" editor_component="image_link"/></p>

<ul>
<li>In the example, a <b>Full backup</b> (Level 0) was performed on December 31st and January 5th. </li>
<li><b>First incremental backups</b> (Level 1):</li>
	<ul>
	<li>Backup level 1 is an incremental backup that only saves changes since the level 0 full backup. </li>
	<li>Note that the first incremental backups are attempted sequentially such as &lt;1-1&gt;, &lt;1-2&gt; and &lt;1-3&gt; in the example, but they are always performed relative to the level 0 full backup. </li>
	<li>Let’s suppose that backup files are created in the same directory. Then, if the first incremental backup &lt;1-1&gt; is performed on January 1st and then the first incremental backup &lt;1-2&gt; is attempted again on January 2nd, the incremental backup file created in &lt;1-1&gt; is overwritten. The final incremental backup file is created on January 3rd because the first incremental backup is performed again on that day. </li>
	<li>Since there can be a possibility that the database needs to be restored the state of January 1st or January 2nd, it is recommended to save the incremental backup files &lt;1-1&gt; and &lt;1-2&gt; separately in a storage media, before overwriting with the final incremental file.</li>
	</ul>
<li><b>Second incremental backup</b> (Level 2):</li>
<ul>
<li>Backup level 2 is an incremental backup that only saves data that have changed since the first incremental backup. </li>
<li>A second incremental backup can be performed only after the first incremental backup. Therefore, the second incremental backup attempted on January 4th will succeed; the one attempted on January 6th fails.</li>
</ul>
</ul>

<p>Backup files created for backup levels 0, 1 and 2 may all be required for database restore. To restore the database to its state on January 4th, for example, you need the second incremental backup generated at &lt;2-1&gt;, the first incremental backup file generated at &lt;1-3&gt;, and the full backup file generated at &lt;0-1&gt;.</p>

<p class="important">For a full restore, backup files from the most recent incremental backup file to the earliest created full backup file are required.</p>

<p>This concludes the 1st part of the CUBRID Backup &amp; Restore tutorial, focused on presenting the CUBRID backup features.</p>
 
<p>Please access the 2nd part of the tutorial to learn about the restore capabilities built into CUBRID.</p>

<h2>See also</h2>

<ul>
<li><a href="/backup_cubrid_database" target="_self">How to Backup a Database in CUBRID</a></li><li><a href="/cubrid_backup_restore_2">CUBRID Backup &amp; Restore – Part II (Restore)</a></li>
<li><a href="/tutorials">CUBRID Tutorials</a></li>
<li><a href="/manual">CUBRID Manual</a></li>
</ul>

<h2>Getting Help</h2>

<p>If you have any questions related to CUBRID Backup, you can <a href="http://twitter.com/?status=%40cubrid%20">tweet to @cubrid</a> or post your message on the <a href="http://forum.cubrid.org/" target="_blank">CUBRID Forum</a>.</p>]]></description>
                        <pubDate>Tue, 08 Feb 2011 07:01:24 -0800</pubDate>
                                </item>
            </channel>
</rss>
