<?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>How to Backup a Database in CUBRID</title>
        <link>http://www.cubrid.org/?mid=backup_cubrid_database</link>
        <description>How to Backup a Database in CUBRID</description>
        <language>en</language>
        <pubDate>Tue, 22 Feb 2011 11:48:12 -0800</pubDate>
        <lastBuildDate>Fri, 08 Apr 2011 11:11:22 -0800</lastBuildDate>
        <generator>XpressEngine 1.4.4.1</generator>
                        										        <item>
            <title>How to Backup a Database in CUBRID</title>
            <dc:creator>admin</dc:creator>
            <link>http://www.cubrid.org/backup_cubrid_database</link>
            <guid isPermaLink="true">http://www.cubrid.org/backup_cubrid_database</guid>
                                    <description><![CDATA[<h1>How to Backup a Database in CUBRID</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="ftp://ftp.cubrid.org/CUBRID_Docs/Tutorials/how-to-backup-a-database-in-cubrid.pdf">Download this document in PDF</a>
</div>

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

<p>One of the main responsibilities of a database administrator is to perform regular backups of the databases, so that they can be restored successfully to a previous state in case of any incidents/system failures.</p>

<p>In particular, a CUBRID database backup is the procedure of creating and storing database volumes, control files, log files. There are two ways you can backup your database in CUBRID:</p>

<ul>
	<li>In the command line using the <b>cubrid backupdb</b> utility.</li>
	<li>Using the <a href="/cubrid_manager" target="_self">CUBRID Manager</a> GUI database administration tool.</li>
</ul>

<p class="important">Note: When we talk about backup and restore, we need to mention that <b>the restore environment must have the same operating system and the same version of CUBRID as the backup environment</b>.</p>

<p class="important">If you need to migrate your database from other database systems to CUBRID or from older version of CUBRID to the latest, there is another dedicated tool called the <a href="/cubrid_migration_toolkit">CUBRID Migration Toolkit</a> (CMT) which supports such scenarios.</p>

<h2>CUBRID backupdb utility</h2>

<p>The syntax of the tool is:</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>For complete information about the usage of this utility, please consult the online manual at <a href="/cubrid_backup_restore#CUBRID-backupdb-utility-1">http://www.cubrid.org/cubrid_backup_restore#CUBRID-backupdb-utility-1</a> or the offline help available within the CUBRID Manager client.</p>

<p class="important"><b>Note</b>: The <b>backupdb</b> utility can only be executed by a user having backup authorization granted (e.g. <b>dba</b>).</p>

<h3>Backup levels</h3>

<p>The key to understand and develop a successful backup strategy is to understand first the <b>CUBRID backup levels</b> concept.</p>

<p>CUBRID supports the following three types of backups:</p>
<ul>
<li><b>Full backup (backup level 0)</b>. Backup level 0 is a backup that includes all database data.  </li>
<li><b>First incremental backup (backup level 1)</b>. Backup level 1 is an incremental backup that only saves the changes made since the level 0 full backup.</li>
<li><b>Second incremental backup (backup level 2)</b>. Backup level 2 is an incremental backup that only saves data that has been changed since the first incremental backup.</li>
</ul>

<p>In other words, the usual strategy to implement a database backup would be to:</p>
<ul>
<li>First create a full database backup – <b>level 0</b>.</li>
<li>Depending on the databases activity/the specifics of your installation, proceed next with <b>level 1</b> incremental backups on a regular basis.</li>
<li>Perform <b>level 2</b> backups <b>“between”</b> the <b>level 1</b> backups, based on your needs to ensure data availability, and taking into account the risks of losing data.</li>
<li>Repeat the previous steps, whenever the differences between the backup levels become too big and will impact the performance/the size of the levels 1 or 2.</li>
</ul>

<p>For example, a backup strategy could be:</p>
<ul>
<li>Perform level 0 backups <b>every week</b></li>
<li>Perform level 1 backups <b>twice a week</b></li>
<li>Perform level 2 backups <b>every day</b></li>
</ul>

<p>Of course, there are no absolute rules and you will have to adapt the backup strategy to best fit the specifics of your CUBRID installation.</p>

<h3>Backup examples</h3>

<p>Let’s use the demodb database and let’s create a full backup (level 0) of the database, in client-server mode – we do not want to close the existing client connections. We will create the backup in a CUBRID installation subfolder – named “backup”. We will use the “–r” parameter, because it is recommended (when performing a full backup) to remove the archive logs. For the other parameters, we will go with the default options:</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 –C -D C:\CUBRID\backup demodb
</div>
</div>

<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>-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>
</tbody>
</table>

<p class="important">Note: In case a backup already exists for the level 0, the user will be prompted to confirm to overwrite it.</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/130/028/backup-level-0-cmd.png" alt="Backup level 0" width="589" height="261" editor_component="image_link"/></p>

<p>Notice that the default naming convention is used for the created backup files:</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/130/028/backup-file-naming-convention.png" alt="Backup file naming convention" width="602" height="170" editor_component="image_link"/></p>

<p>If we want to have more information about the backup, we can use the “<b>-o</b>” option to output the logs to the file; remember, when you use the “<b>-o</b>” option, the path you specify for the file where backup information will be dumped is relative to the CUBRID installation folder:</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/130/028/backup-log-output.png" alt="Backup log output" width="587" height="85" editor_component="image_link"/></p>

<p>And here is the information which is stored in the specified file:</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/130/028/backup-log-file.png" alt="Backup log file" width="602" height="363" editor_component="image_link"/></p>

<p>Tip: Remember, you can always see the list of the available database backups using the <b>restoredb</b> utility:</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 restoredb --list demodb
</div>
</div>

<p><img src="http://www.cubrid.org/files/attach/images/49/130/028/backup-list-using-restoredb.png" alt="Backup list using restoredb" width="551" height="468" editor_component="image_link"/></p>

<p>Once we have created a full backup of the database, we can proceed further with creating a <b>level 1</b> backup:</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 –1 –r –C -D C:\CUBRID\backup demodb
</div>
</div>

<p><img src="http://www.cubrid.org/files/attach/images/49/130/028/backup-level-1.png" alt="Backup level 1" width="587" height="69" editor_component="image_link"/></p>

<p><img src="http://www.cubrid.org/files/attach/images/49/130/028/backup-level-1-log-file.png" alt="Backup level 1 log file" width="602" height="170" editor_component="image_link"/></p>

<p>And once having a level 1 backup in place, we can now finally create <b>level 2</b> backups. They can be created whenever needed, there is not required to re-create a level 1 backup every time before:</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/130/028/backup-level-2.png" alt="Backup level 2" width="579" height="201" editor_component="image_link"/></p>

<p><img src="http://www.cubrid.org/files/attach/images/49/130/028/backup-level-2-log-file.png" alt="Backup level 2 log file" width="601" height="308" editor_component="image_link"/></p>

<p>As you can see from the above examples, making a CUBRID database backup is very easy. The process itself consists of just running a single command and it executes very fast. There are multiple options you can use with the tool, to facilitate obtaining the results you need.</p>

<h2>Backup database using CUBRID Manager Client</h2>

<p>In the previous examples, we showed you how to create various backups using the command line tool (backupdb). But in addition to this solution, there is another easy way to create database backups – which is using the graphical interface provided by the CUBRID Manager client.</p>

<p>To backup a database using the CUBRID Manager client, use one of the following ways:</p>

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

<p>In the previous examples, we showed you how to create various backups using the command line tool (<b>backupdb</b>). But in addition to this solution, there is another easy way to create database backups – which is using the graphical interface provided by the CUBRID Manager client.</p>

<p>To backup a database using the CUBRID Manager client, use one of the following ways:</p>

<ul>
<li>Click the <b>Backup Database</b> <img src="http://www.cubrid.org/files/attach/images/49/130/028/cm-backup-db-icon.png" alt="Backup database button" width="16" height="16" editor_component="image_link"/> icon from the toolbar</li>
<li>Right-click the database in the tree and then select the <b>Backup Database</b> item</li>
<li>Select <b>Action -&gt; Backup Database</b> from the main menu</li>
</ul>

<p>Once you select <b>Backup Database</b> the following dialog will be displayed, where you can specify the backup options:</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/130/028/cm-backup-db.png" alt="CM backup database dialog.png" width="602" height="353" editor_component="image_link"/></p>

<p>If a backup has been successfully created for the database, you can check the backup history from the <b>Backup History Information</b> tab, in the dialog above:</p>

<p><img src="http://www.cubrid.org/files/attach/images/49/130/028/cm-backup-history.png" alt="CM backup history" width="601" height="286" editor_component="image_link"/></p>

<h2>Backup Automation in the CUBRID Manager Client</h2>

<p class="important">Not only you can easily create backup from the interface, but you can schedule automatic backups using the CUBRID Manager client interface.</p>

<p>When you login to the database, you have access to the <b>Backup plan</b> entry, 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/130/028/cm-backup-automation.png" alt="CM backup automation" width="396" height="264" editor_component="image_link"/></p>

<p>If you want to activate a backup periodically, you will have to configure it, using the <b>Add Backup Plan</b> option:</p>

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

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

<p>And there is more to discover, so we encourage you to try using all the rich backup options provided by the CUBRID Manager client, to learn the most effective ways to implement a successful backup strategy.</p>

<h2>See also</h2>

<ul>
	<li><a href="/restore_cubrid_database" target="_self">How to Restore a Database in CUBRID</a></li><li><a href="/cubrid_backup_restore">CUBRID Backup &amp; Restore – Part I (Backup)</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>
</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, 22 Feb 2011 10:48:45 -0800</pubDate>
                                </item>
            </channel>
</rss>
