This file is indexed.

/usr/share/doc/python-apsw/html/_sources/backup.txt is in python-apsw-doc 3.8.6-r1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
.. Automatically generated by code2rst.py
   code2rst.py src/backup.c doc/backup.rst
   Edit src/backup.c not this file!

.. currentmodule:: apsw

.. _backup:

Backup
******

A backup object encapsulates copying one database to another.  You
call :meth:`Connection.backup` on the destination database to get the
backup object.  Call :meth:`~backup.step` to copy some pages
repeatedly dealing with errors as appropriate.  Finally
:meth:`~backup.finish` cleans up committing or rolling back and
releasing locks.

Here is an example usage using the **with** statement to ensure
:meth:`~backup.finish` is called::

  # copies source.main into db
  with db.backup("main", source, "main") as b:
      while not b.done:
          b.step(100)
          print b.remaining, b.pagecount, "\r",

If you are not using **with** then you'll need to ensure
:meth:`~backup.finish` is called::

  # copies source.main into db
  b=db.backup("main", source, "main")
  try:
      while not b.done:
          b.step(100)
          print b.remaining, b.pagecount, "\r",
  finally:
      b.finish()

Important details
=================

The database is copied page by page.  This means that there is not a
round trip via SQL.  All pages are copied including free ones.

The destination database is locked during the copy.  You will get a
:exc:`ThreadingViolationError` if you attempt to use it.

backup class
============

.. class:: backup

  You create a backup instance by calling :meth:`Connection.backup`.

.. method:: backup.__enter__() -> self

  You can use the backup object as a `context manager
  <http://docs.python.org/reference/datamodel.html#with-statement-context-managers>`_
  as defined in :pep:`0343`.  The :meth:`~backup.__exit__` method ensures that backup
  is :meth:`finished <backup.finish>`.

.. method:: backup.__exit__() -> False

  Implements context manager in conjunction with :meth:`~backup.__enter__` ensuring
  that the copy is :meth:`finished <backup.finish>`.

.. method:: backup.close([force=False])

  Does the same thing as :meth:`~backup.finish`.  This extra api is
  provided to give the same api as other APSW objects such as
  :meth:`Connection.close`, :meth:`blob.close` and
  :meth:`Cursor.close`.  It is safe to call this method multiple
  times.

  :param force: If true then any exceptions are ignored.

.. attribute:: backup.done

  A boolean that is True if the copy completed in the last call to :meth:`~backup.step`.

.. index:: sqlite3_backup_finish

.. method:: backup.finish()

  Completes the copy process.  If all pages have been copied then the
  transaction is committed on the destination database, otherwise it
  is rolled back.  This method must be called for your backup to take
  effect.  The backup object will always be finished even if there is
  an exception.  It is safe to call this method multiple times.

  Calls: :sqliteapi:`sqlite3_backup_finish <backup_finish.html#sqlite3backupf>`

.. index:: sqlite3_backup_pagecount

.. attribute:: backup.pagecount

  Read only. How many pages were in the source database after the last
  step.  If you haven't called :meth:`~backup.step` or the backup
  object has been :meth:`finished <backup.finish>` then zero is
  returned.

  Calls: :sqliteapi:`sqlite3_backup_pagecount <backup_finish.html#sqlite3backupf>`

.. index:: sqlite3_backup_remaining

.. attribute:: backup.remaining

  Read only. How many pages were remaining to be copied after the last
  step.  If you haven't called :meth:`~backup.step` or the backup
  object has been :meth:`finished <backup.finish>` then zero is
  returned.

  Calls: :sqliteapi:`sqlite3_backup_remaining <backup_finish.html#sqlite3backupf>`

.. index:: sqlite3_backup_step

.. method:: backup.step([npages=All]) -> bool

  Copies *npages* pages from the source to destination database.  The source database is locked during the copy so
  using smaller values allows other access to the source database.  The destination database is always locked until the
  backup object is :meth:`finished <backup.finish>`.

  :param npages: How many pages to copy. If the parameter is omitted
     or negative then all remaining pages are copied. The default page
     size is 1024 bytes (1kb) which can be changed before database
     creation using a `pragma
     <https://sqlite.org/pragma.html#modify>`_.

  This method may throw a :exc:`BusyError` or :exc:`LockedError` if
  unable to lock the source database.  You can catch those and try
  again.

  :returns: True if this copied the last remaining outstanding pages, else false.  This is the same value as :attr:`~backup.done`

  Calls: :sqliteapi:`sqlite3_backup_step <backup_finish.html#sqlite3backupf>`