<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="sqlite3.backup" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
 <refnamediv>
  <refname>SQLite3::backup</refname>
  <refpurpose>Backup one database to another database</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis role="SQLite3">
   <modifier>public</modifier> <type>bool</type><methodname>SQLite3::backup</methodname>
   <methodparam><type>SQLite3</type><parameter>destination</parameter></methodparam>
   <methodparam choice="opt"><type>string</type><parameter>sourceDatabase</parameter><initializer>"main"</initializer></methodparam>
   <methodparam choice="opt"><type>string</type><parameter>destinationDatabase</parameter><initializer>"main"</initializer></methodparam>
  </methodsynopsis>
  <para>
   <methodname>SQLite3::backup</methodname> copies the contents of one database
   into another, overwriting the contents of the destination database.
   It is useful either for creating backups of databases
   or for copying in-memory databases to or from persistent files.
  </para>
  <tip>
   <para>
    As of SQLite 3.27.0 (2019-02-07), it is also possible to use the statement
    <literal>VACUUM INTO 'file.db';</literal> to backup the database to a new file.
   </para>
  </tip>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <variablelist>
   <varlistentry>
    <term><parameter>destination</parameter></term>
    <listitem>
     <para>
      A database connection opened with <methodname>SQLite3::open</methodname>.
     </para>
    </listitem>
   </varlistentry>
   <varlistentry>
    <term><parameter>sourceDatabase</parameter></term>
    <listitem>
     <para>
      The database name is <literal>"main"</literal> for the main database,
      <literal>"temp"</literal> for the temporary database,
      or the name specified after the <literal>AS</literal> keyword
      in an <literal>ATTACH</literal> statement for an attached database.
     </para>
    </listitem>
   </varlistentry>
   <varlistentry>
    <term><parameter>destinationDatabase</parameter></term>
    <listitem>
     <para>
      Analogous to <parameter>sourceDatabase</parameter>
      but for the <parameter>destination</parameter>.
     </para>
    </listitem>
   </varlistentry>
  </variablelist>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   &return.success;
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <example xml:id="sqlite3.backup.example.basic">
   <title>Backup an existing database</title>
   <programlisting role="php">
<![CDATA[
<?php
// $conn is a connection to an already opened sqlite3 database

$backup = new SQLite3('backup.sqlite');
$conn->backup($backup);
?>
]]>
   </programlisting>
  </example>
 </refsect1>

</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
