<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h4 class="title">
      <a name="replication-solutions-backups-mysqldump">
      </a>
      19.4.1.1 Backing Up a Replica Using mysqldump
     </h4>
    </div>
   </div>
  </div>
  <p>
   Using
   <a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
    <span class="command">
     <strong>
      mysqldump
     </strong>
    </span>
   </a>
   to create a copy of a
        database enables you to capture all of the data in the database
        in a format that enables the information to be imported into
        another instance of MySQL Server (see
   <a class="xref" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
    Section 6.5.4, “mysqldump — A Database Backup Program”
   </a>
   ). Because the format of the
        information is SQL statements, the file can easily be
        distributed and applied to running servers in the event that you
        need access to the data in an emergency. However, if the size of
        your data set is very large,
   <a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
    <span class="command">
     <strong>
      mysqldump
     </strong>
    </span>
   </a>
   may be
        impractical.
  </p>
  <div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Tip
   </div>
   <p>
    Consider using the
    <a class="ulink" href="/doc/mysql-shell/8.4/en/mysql-shell-utilities-dump-instance-schema.html" target="_top">
     MySQL Shell dump utilities
    </a>
    , which provide parallel dumping with multiple threads, file compression, and progress information display, as well as cloud features such as Oracle Cloud Infrastructure Object Storage streaming, and MySQL HeatWave Service compatibility checks and modifications. Dumps can be easily imported into a MySQL Server instance or a MySQL HeatWave Service DB System using the
    <a class="ulink" href="/doc/mysql-shell/8.4/en/mysql-shell-utilities-load-dump.html" target="_top">
     MySQL Shell load dump utilities
    </a>
    . Installation instructions for MySQL Shell can be found
    <a class="ulink" href="/doc/mysql-shell/8.4/en/mysql-shell-install.html" target="_top">
     here
    </a>
    .
   </p>
  </div>
  <p>
   When using
   <a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
    <span class="command">
     <strong>
      mysqldump
     </strong>
    </span>
   </a>
   , you should stop
        replication on the replica before starting the dump process to
        ensure that the dump contains a consistent set of data:
  </p>
  <div class="orderedlist">
   <ol class="orderedlist" type="1">
    <li class="listitem">
     <p>
      Stop the replica from processing requests. You can stop
            replication completely on the replica using
      <a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
       <span class="command">
        <strong>
         mysqladmin
        </strong>
       </span>
      </a>
      :
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa8257958"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">mysqladmin</span> stop-replica</code></pre>
     </div>
     <p>
      Alternatively, you can stop only the replication SQL thread
            to pause event execution:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa58383647"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">mysql</span> <span class="token property">-e</span> <span class="token atrule">'STOP REPLICA SQL_THREAD;'</span></code></pre>
     </div>
     <p>
      This enables the replica to continue to receive data change
            events from the source's binary log and store them in the
            relay logs using the replication receiver thread, but
            prevents the replica from executing these events and
            changing its data. Within busy replication environments,
            permitting the replication receiver thread to run during
            backup may speed up the catch-up process when you restart
            the replication applier thread.
     </p>
    </li>
    <li class="listitem">
     <p>
      Run
      <a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
       <span class="command">
        <strong>
         mysqldump
        </strong>
       </span>
      </a>
      to dump your databases. You
            may either dump all databases or select databases to be
            dumped. For example, to dump all databases:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa1448280"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">mysqldump</span> <span class="token property">--all-databases</span> &gt; fulldb<span class="token punctuation">.</span>dump</code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      Once the dump has completed, start replication again:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa76738624"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">mysqladmin</span> start-replica</code></pre>
     </div>
    </li>
   </ol>
  </div>
  <p>
   In the preceding example, you may want to add login credentials
        (user name, password) to the commands, and bundle the process up
        into a script that you can run automatically each day.
  </p>
  <p>
   If you use this approach, make sure you monitor the replication
        process to ensure that the time taken to run the backup does not
        affect the replica's ability to keep up with events from the
        source. See
   <a class="xref" href="replication-administration-status.html" title="19.1.7.1 Checking Replication Status">
    Section 19.1.7.1, “Checking Replication Status”
   </a>
   .
        If the replica is unable to keep up, you may want to add another
        replica and distribute the backup process. For an example of how
        to configure this scenario, see
   <a class="xref" href="replication-solutions-partitioning.html" title="19.4.6 Replicating Different Databases to Different Replicas">
    Section 19.4.6, “Replicating Different Databases to Different Replicas”
   </a>
   .
  </p>
 </div>
 <br/>
</div>
