~akopytov/percona-xtrabackup/xtrabackup-1.6-copy-diagnostics

« back to all changes in this revision

Viewing changes to doc/source/innobackupex/how_innobackupex_works.rst

  • Committer: Hrvoje Matijakovic
  • Date: 2012-02-16 17:05:16 UTC
  • Revision ID: hrvoje.matijakovic@percona.com-20120216170516-s3b0nk7x6av63b7t
imported the sphinx docs from the current trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
.. _how_ibk_works:
 
2
 
 
3
==========================
 
4
 How |innobackupex| Works
 
5
==========================
 
6
 
 
7
:program:`innobackupex` is a script written in Perl that wraps the :program:`xtrabackup` and :program:`tar4ibd` binaries and performs the tasks where the performance and efficiency of *C* program isn't needed. In this way, it provides a convinient and integrated approach to backing up in many common scenarios. 
 
8
 
 
9
The following describes the rationale behind :program:`innobackupex` actions.
 
10
 
 
11
.. _making-backup-ibk:
 
12
 
 
13
Making a Backup
 
14
===============
 
15
 
 
16
If no mode is specified, |innobackupex| will assume the backup mode.
 
17
 
 
18
By default, it starts :program:`xtrabackup` with the :option:`--suspend-at-end` option, and lets it copy the InnoDB data files. When :program:`xtrabackup` finishes that, :program:`innobackupex` sees it create the :file:`xtrabackup_suspended` file and executes ``FLUSH TABLES WITH READ LOCK``. Then it begins copying the rest of the files.
 
19
 
 
20
If the :option:`--ibbackup` is not supplied, |innobackupex| will try to detect it: if the :file:`xtrabackup_binary` file exists on the backup directory, it reads from it which binary of |xtrabackup| will be used. Otherwise, it will try to connect to the database server in order to determine it. If the connection can't be established, |xtrabackup| will fail and you must specify it (see :ref:`ibk-right-binary`).
 
21
 
 
22
When the binary is determined, the connection to the database server is checked. This done by connecting, issuing a query, and closing the connection. If everything goes well, the binary is started as a child process.
 
23
 
 
24
If it is not an incremental backup, it connects to the server. It waits for slaves in a replication setup if the option :option:`--safe-slave-backup` is set and will flush all tables with **READ LOCK**, preventing all |MyISAM| tables from writing (unless option :option:`--no-lock` is specified).
 
25
 
 
26
Once this is done, the backup of the files will begin. It will backup :term:`.frm`, :term:`.MRG`, :term:`.MYD`, :term:`.MYI`, :term:`.TRG`, :term:`.TRN`, :term:`.ARM`, :term:`.ARZ`, :term:`.CSM`, :term:`.CSV` and :term:`.opt` files.
 
27
 
 
28
When all the files are backed up, it resumes :program:`ibbackup` and wait until it finishes copying the transactions done while the backup was done. Then, the tables are unlocked, the slave is started (if the option :option:`--safe-slave-backup` was used) and the connection with the server is closed. Then, it removes the :file:`xtrabackup_suspended` file and permits :program:`xtrabackup` to exit.
 
29
 
 
30
It  will also create the following files in the directory of the backup:
 
31
 
 
32
:file:`xtrabackup_checkpoints`
 
33
   containing the :term:`LSN` and the type of backup;
 
34
 
 
35
:file:`xtrabackup_binlog_info` 
 
36
   containing the position of the binary log at the moment of backing up;
 
37
 
 
38
:file:`xtrabackup_binlog_pos_innodb`
 
39
   containing the position of the binary log at the moment of backing up relative to |InnoDB| transactions;
 
40
 
 
41
:file:`xtrabackup_slave_info`
 
42
   containing the MySQL binlog position of the master server in a replication setup via ``'SHOW SLAVE STATUS\G;'`` if the :option:`--slave-info` option is passed;
 
43
 
 
44
:file:`backup-my.cnf`
 
45
   containing only the :file:`my.cnf` options required for the backup;
 
46
 
 
47
:file:`xtrabackup_binary` 
 
48
   containing the binary used for the backup;
 
49
 
 
50
:file:`mysql-stderr`
 
51
  containing the ``STDERR`` of :program:`mysqld` during the process and
 
52
 
 
53
:file:`mysql-stdout`
 
54
  containing the ``STDOUT`` of the server.
 
55
 
 
56
If the :option:`--remote-host` was set, |innobackupex| will test the connection to the host via :command:`ssh` and create the backup directories. Then the same process will be applied but the log will be written to a temporary file and will be copied via :command:`scp` with the options set by :option:`--scpopt` (``-Cp -c arcfour`` by default).
 
57
 
 
58
After each copy the files will be deleted. The same rationale is for the :option:`--stream` mode.
 
59
 
 
60
Finally, the binary log position will be printed to ``STDERR`` and |innobackupex| will exit returning 0 if all went OK.
 
61
 
 
62
Note that the ``STDERR`` of |innobackupex| is not written in any file. You will have to redirect it to a file, e.g., ``innobackupex OPTIONS 2> backupout.log``.
 
63
 
 
64
.. _copy-back-ibk:
 
65
 
 
66
Restoring a backup
 
67
==================
 
68
 
 
69
To restore a backup with |innobackupex| the :option:`--copy-back` option must be used.
 
70
 
 
71
|innobackupex| will read the read from the :file:`my.cnf` the variables :term:`datadir`, :term:`innodb_data_home_dir`, :term:`innodb_data_file_path`, :term:`innodb_log_group_home_dir` and check that the directories exist.
 
72
 
 
73
It will copy the |MyISAM| tables, indexes, etc. (:term:`.frm`, :term:`.MRG`, :term:`.MYD`, :term:`.MYI`, :term:`.TRG`, :term:`.TRN`, :term:`.ARM`, :term:`.ARZ`, :term:`.CSM`, :term:`.CSV` and :term:`.opt` files) first, |InnoDB| tables and indexes next and the log files at last. It will preserve file's attributes when copying them, you may have to change the files' ownership to ``mysql`` before starting the database server, as they will be owned by the user who created the backup.