Merge lp:~hrvojem/percona-xtrabackup/bug1204710-2.1 into lp:percona-xtrabackup/2.1

Proposed by Hrvoje Matijakovic
Status: Merged
Approved by: Alexey Kopytov
Approved revision: no longer in the source branch.
Merged at revision: 702
Proposed branch: lp:~hrvojem/percona-xtrabackup/bug1204710-2.1
Merge into: lp:percona-xtrabackup/2.1
Diff against target: 1567 lines (+7/-1541)
3 files modified
doc/source/conf.py (+7/-1)
doc/source/manindex.rst (+0/-69)
doc/xtrabackup.1 (+0/-1471)
To merge this branch: bzr merge lp:~hrvojem/percona-xtrabackup/bug1204710-2.1
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Approve
Review via email: mp+198391@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Alexey Kopytov (akopytov) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'doc/source/conf.py'
2--- doc/source/conf.py 2013-11-21 10:08:38 +0000
3+++ doc/source/conf.py 2013-12-10 16:27:02 +0000
4@@ -260,6 +260,12 @@
5 # One entry per manual page. List of tuples
6 # (source start file, name, description, authors, manual section).
7 man_pages = [
8- ('manindex', 'xtrabackup', u'Percona XtraBackup Documentation',
9+ ('xtrabackup_bin/xtrabackup_binary', 'xtrabackup', u'Percona XtraBackup Documentation',
10+ [u'Percona LLC and/or its affiliates'], 1),
11+ ('innobackupex/innobackupex_script', 'innobackupex', u'innobackupex Documentation',
12+ [u'Percona LLC and/or its affiliates'], 1),
13+ ('xbcrypt/xbcrypt', 'xbcrypt', u'Percona xbcrypt Documentation',
14+ [u'Percona LLC and/or its affiliates'], 1),
15+ ('xbstream/xbstream', 'xbstream', u'Percona xbstream Documentation',
16 [u'Percona LLC and/or its affiliates'], 1)
17 ]
18
19=== removed file 'doc/source/manindex.rst'
20--- doc/source/manindex.rst 2013-08-30 09:55:04 +0000
21+++ doc/source/manindex.rst 1970-01-01 00:00:00 +0000
22@@ -1,69 +0,0 @@
23-.. Percona Xtrabackup documentation master file, created by
24- sphinx-quickstart on Fri May 6 01:04:39 2011.
25- You can adapt this file completely to your liking, but it should at least
26- contain the root `toctree` directive.
27-
28-====================================
29- Percona Xtrabackup - Documentation
30-====================================
31-
32-|Percona XtraBackup| is an open-source hot backup utility for |MySQL| - based servers that doesn't lock your database during the backup.
33-
34-It can back up data from |InnoDB|, |XtraDB|, and |MyISAM| tables on unmodified |MySQL| 5.1 and 5.5 servers, as well as |Percona Server| with |XtraDB|. For a high-level overview of many of its advanced features, including a feature comparison, please see :doc:`intro`.
35-
36-Whether it is a 24x7 highly loaded server or a low-transaction-volume environment, |Percona XtraBackup| is designed to make backups a seamless procedure without disrupting the performance of the server in a production environment. `Commercial support contracts are available <http://www.percona.com/mysql-support/>`_.
37-
38-|Percona XtraBackup| is a combination of the |xtrabackup| *C* program, and the |innobackupex| *Perl* script. The |xtrabackup| program copies and manipulates |InnoDB| and |XtraDB| data files, and the *Perl* script enables enhanced functionality, such as interacting with a running |MySQL| server and backing up |MyISAM| tables. |Percona XtraBackup| works with unmodified |MySQL| servers, as well as |Percona Server| with |XtraDB|. It runs on *Linux* and *FreeBSD*.
39-
40-Introduction
41-============
42-
43-.. toctree::
44- :maxdepth: 1
45- :glob:
46-
47- intro
48-
49-User's Manual
50-=============
51-
52-.. toctree::
53- :maxdepth: 2
54- :glob:
55-
56- manual
57-
58-Tutorials, Recipes, How-tos
59-===========================
60-
61-.. toctree::
62- :maxdepth: 2
63- :hidden:
64-
65- how-tos
66-
67-* :ref:`recipes-xbk`
68-
69-* :ref:`recipes-ibk`
70-
71-* :ref:`howtos`
72-
73-* :ref:`aux-guides`
74-
75-Miscellaneous
76-=============
77-
78-.. toctree::
79- :maxdepth: 1
80- :glob:
81-
82- glossary
83- trademark-policy
84-
85-Indices and tables
86-==================
87-
88-* :ref:`genindex`
89-
90-* :ref:`search`
91-
92
93=== removed file 'doc/xtrabackup.1'
94--- doc/xtrabackup.1 2013-08-18 06:54:14 +0000
95+++ doc/xtrabackup.1 1970-01-01 00:00:00 +0000
96@@ -1,1471 +0,0 @@
97-.TH "XtraBackup" 1 "January 2011" "" "Percona LLC and/or its affiliates"
98-.SH "NAME"
99-Percona XtraBackup
100-.SH "DESCRIPTION"
101-.P
102-Percona XtraBackup is an open-source hot backup utility for MySQL that doesn't lock your database during the backup. It can back up data from InnoDB, XtraDB, and MyISAM tables on MySQL 5.0 and 5.1 servers, and it has many advanced features. Commercial support is available(http://www.percona.com/support/mysql-support-maintenance/).
103-.P
104-Percona XtraBackup is a combination of the xtrabackup C program, and the innobackupex Perl script. The xtrabackup program copies and manipulates InnoDB and XtraDB data files, and the Perl script enables enhanced functionality, such as interacting with a running MySQL server and backing up MyISAM tables. XtraBackup works with unmodified MySQL servers, as well as Percona Server with XtraDB. It runs on Linux, Windows, and FreeBSD.
105-.P
106-Summary of features:
107-
108-.P
109-.B
110-Hot backups.
111-Backups are online, and queries and transactions continue to run without interruption.
112-.P
113-.B
114-Backs up MyISAM.
115-MyISAM tables are read-only while they are being backed up.
116-.P
117-.B
118-Partial backups.
119-You can select which tables and databases to back up.
120-.P
121-.B
122-High performance.
123-XtraBackup is fast and low-impact. It takes special care not to disrupt your database server. It can copy files in parallel (in multiple threads) for even higher performance.
124-.P
125-.B
126-Remote backups.
127-You can make local backups, you can stream the backups to other programs, or you can securely copy your backups to a remote host after completion.
128-.P
129-.B
130-Compressed backups.
131-You can stream a backup into a compressed format. There is a companion program tar4ibd that understands how to work with InnoDB's data format.
132-.P
133-.B
134-Incremental (delta) backups.
135-You can back up only the data pages that have changed since the last backup.
136-.P
137-.B
138-Point-in-time recovery.
139-You can recover a backup, and then use binary logs to roll forward to a point in time.
140-
141-.SH " Percona XtraBackup User Manual "
142-
143-
144-This page explains how to use Percona XtraBackup. XtraBackup is really a set of three tools:
145-
146-.HP
147-*
148-.B "xtrabackup"
149-- a compiled C binary, which copies only InnoDB and XtraDB data
150-.HP
151-*
152-.B "innobackupex"
153-- a wrapper script that provides functionality to backup a whole MySQL database instance with MyISAM, InnoDB, and XtraDB tables.
154-.HP
155-*
156-.B "tar4ibd"
157-- tars InnoDB data safely.
158-
159-It is possible to use the
160-.B "xtrabackup"
161-binary alone, or to use only the
162-.B "innobackupex"
163-wrapper script and let it execute
164-.B "xtrabackup"
165-for you. It might be helpful to first learn how to use
166-.B "xtrabackup"
167-, and then learn how to use
168-.B "innobackupex"
169-for convenience and added functionality.
170-
171-.SS " How XtraBackup Works "
172-
173-
174-XtraBackup is based on InnoDB's crash-recovery functionality. It copies your InnoDB data files, which results in data that is internally inconsistent; but then it performs crash recovery on the files to make them a consistent, usable database again.
175-
176-This works because InnoDB maintains a
177-.I "redo log"
178-, also called the transaction log. This contains a record of every change to InnoDB's data. When InnoDB starts, it inspects the data files and the transaction log, and performs two steps. It applies committed transaction log entries to the data files, and it performs an undo operation on any transactions that modified data but did not commit.
179-
180-XtraBackup works by remembering the
181-.I "log sequence number"
182-(LSN) when it starts, and then copying away the data files. It takes some time to do this, so if the files are changing, then they reflect the state of the database at different points in time. At the same time, XtraBackup runs a background process that watches the transaction log files, and copies changes from it. XtraBackup needs to do this continually because the transaction logs are written in a round-robin fashion, and can be reused after a while. XtraBackup needs the transaction log records for every change to the data files since it began execution.
183-
184-The above is the
185-.I "backup"
186-process. Next is the
187-.I "prepare"
188-process. During this step, XtraBackup performs crash recovery against the copied data files, using the copied transaction log file. After this is done, the database is ready to restore and use.
189-
190-The above process is implemented in the
191-.B "xtrabackup"
192-compiled binary program. The
193-.B "innobackupex"
194-program adds more convenience and functionality by also permitting you to back up MyISAM tables and .frm files. It starts
195-.B "xtrabackup"
196-, waits until it finishes copying files, and then issues
197-.B "FLUSH TABLES WITH READ LOCK"
198-to prevent further changes to MySQL's data and flush all MyISAM tables to disk. It holds this lock, copies the MyISAM files, and then releases the lock.
199-
200-The backed-up MyISAM and InnoDB tables will eventually be consistent with each other, because after the prepare (recovery) process, InnoDB's data is rolled forward to the point at which the backup completed, not rolled back to the point at which it started. This point in time matches where the
201-.B "FLUSH TABLES WITH READ LOCK"
202-was taken, so the MyISAM data and the prepared InnoDB data are in sync.
203-
204-The
205-.B "xtrabackup"
206-and
207-.B "innobackupex"
208-tools both offer many features not mentioned in the preceding explanation. Each tool's functionality is explained in more detail on its manual page. In brief, though, the tools permit you to do operations such as streaming and incremental backups with various combinations of copying the data files, copying the log files, and applying the logs to the data.
209-
210-.SH " The xtrabackup Binary "
211-
212-
213-The
214-.B "xtrabackup"
215-binary is a compiled C program that is linked with the InnoDB libraries and the standard MySQL client libraries. The InnoDB libraries provide functionality necessary to apply a log to data files, and the MySQL client libraries provide command-line option parsing, configuration file parsing, and so on to give the binary a familiar look and feel.
216-
217-The next step is to
218-.B "--prepare"
219-your backup so it is ready to restore.
220-The
221-.B "xtrabackup"
222-tool runs in either
223-.B "--backup"
224-or
225-.B "--prepare"
226-mode, corresponding to the two main functions it performs. There are several variations on these functions to accomplish different tasks, and there are two less commonly used modes,
227-.B "--stats"
228-and
229-.B "--print-param"
230-. There is no need to use any wrapper script with
231-.B "xtrabackup"
232-if you don't want to. It is quite easy to use by itself for most purposes.
233-
234-This manual section explains how to use xtrabackup in detail.
235-.SH " Creating a Backup "
236-
237-
238-To create a backup, run
239-.B "xtrabackup"
240-with the
241-.B "--backup"
242-option. You also need to specify a
243-.B "--target_dir"
244-option, which is where the backup will be stored, and a
245-.B "--datadir"
246-option, which is where the MySQL data is stored. If the InnoDB data or log files aren't stored in the same directory, you might need to specify the location of those, too. If the target directory does not exist,
247-.B "xtrabackup"
248-creates it. If the directory does exist and is empty,
249-.B "xtrabackup"
250-will succeed.
251-.B "xtrabackup"
252-will not overwrite existing files, however; it will fail with operating system error 17, 'file exists.'
253-
254-The tool changes its working directory to the data directory and performs two primary tasks to complete the backup:
255-
256- - It starts a log-copying thread in the background. This thread watches the InnoDB log files, and when they change, it copies the changed blocks to a file called
257-.B "xtrabackup_logfile"
258-in the backup target directory. This is necessary because the backup might take a long time, and the recovery process needs all of the log file entries from the beginning to the end of the backup.
259- - It copies the InnoDB data files to the target directory. This is not a simple file copy; it opens and reads the files similarly to the way InnoDB does, by reading the data dictionary and copying them a page at a time.
260-
261-When the data files are finished copying, xtrabackup stops the log-copying thread, and creates a files in the target directory called
262-.B "xtrabackup_checkpoints"
263-, which contains the type of backup performed, the log sequence number at the beginning, and the log sequence number at the end.
264-
265-An example command to perform a backup follows:
266-
267-
268-.nf
269-
270-xtrabackup --backup --datadir=/var/lib/mysql/ --target-dir=/data/backups/mysql/
271-
272-.fi
273-
274-This takes a backup of
275-.B "/var/lib/mysql"
276-and stores it at
277-.B "/data/backups/mysql/"
278-. The
279-.B "--target-dir"
280-option deserves special explanation. Because the backup is performed from the data directory itself,
281-.B "the target directory is relative to the data directory"
282-unless you specify an absolute path. If you specify a relative path such as
283-.B "--target-dir=backups"
284-, for example, don't look for the backup in the directory from which you executed xtrabackup -- it will be a subdirectory of the
285-.B "--datadir"
286-directory instead!
287-
288-During the backup process, you should see a lot of output showing the data files being copied, as well as the log file thread repeatedly scanning the log files and copying from it. The last thing you should see is something like the following, where the value of the <LSN> will be a number that depends on your system:
289-
290-
291-.nf
292-
293-xtrabackup: Transaction log of lsn (<SLN>) to (<LSN>) was copied.
294-
295-.fi
296-
297-After the backup is finished, the target directory will contain files such as the following, assuming you have a single InnoDB table
298-.B "test.tbl1"
299-and you are using
300-.B "innodb_file_per_table"
301-:
302-
303-
304-.nf
305-
306-/data/backups/mysql/ibdata1
307-/data/backups/mysql/test
308-/data/backups/mysql/test/tbl1.ibd
309-/data/backups/mysql/xtrabackup_checkpoints
310-/data/backups/mysql/xtrabackup_logfile
311-
312-.fi
313-
314-The backup can take a long time, depending on how large the database is. It is safe to cancel at any time, because it does not modify the database.
315-
316-.SH " Preparing the Backup "
317-
318-
319-After you make a backup with
320-.B "--backup"
321-, the next step is to
322-.I "prepare"
323-it. The data files are not point-in-time consistent until they've been prepared, because they were copied at different times as the program ran, and they might have been changed while this was happening. If you try to start InnoDB with these data files, it will detect corruption and crash itself to prevent you from running on damaged data. The prepare step makes the files perfectly consistent at a single instant in time, so you can run InnoDB on them.
324-
325-During the prepare operation, xtrabackup boots up a kind of modified InnoDB that's embedded inside it (the libraries it was linked against). The modifications are necessary to disable InnoDB's standard safety checks, such as complaining that the log file isn't the right size, which aren't appropriate for working with backups. These modifications are only for the xtrabackup binary; you don't need a modified InnoDB to use xtrabackup for your backups.
326-
327-The prepare step uses this "embedded InnoDB" to perform crash recovery on the copied datafiles, using the copied log file. The prepare step is very simple to use: you simply run xtrabackup with the
328-.B "--prepare"
329-option and tell it which directory to prepare, for example, to prepare the backup previously taken,
330-
331-
332-.nf
333-
334-xtrabackup --prepare --target-dir=/data/backups/mysql/
335-
336-.fi
337-
338-When this finishes, you should see an "InnoDB shutdown" with a message such as the following, where again the value of <LSN> will depend on your system:
339-
340-
341-.nf
342-
343-101107 16:40:15 InnoDB: Shutdown completed; log sequence number <LSN>
344-
345-.fi
346-
347-Your backup is now clean and consistent, and ready to
348-.B "restore"
349-. However, you might want to take an extra step to make restores as quick as possible. This is to prepare the backup a second time. The first time makes the data files perfectly self-consistent, but it doesn't create fresh InnoDB log files. If you restore the backup at this point and start MySQL, it will have to create new log files, which could take a little while, and you might not want to wait for that. If you run
350-.B "--prepare"
351-a second time, xtrabackup will create the log files for you, and output status text such as the following, which is abbreviated for clarity. The value of <SIZE> will depend on your MySQL configuration.
352-
353-
354-.nf
355-
356-$ xtrabackup --prepare --target-dir=/data/backups/mysql/
357-xtrabackup: This target seems to be already prepared.
358-xtrabackup: notice: xtrabackup_logfile was already used to '--prepare'.
359-101107 16:54:10 InnoDB: Log file ./ib_logfile0 did not exist: new to be created
360-InnoDB: Setting log file ./ib_logfile0 size to <SIZE> MB
361-InnoDB: Database physically writes the file full: wait...
362-101107 16:54:10 InnoDB: Log file ./ib_logfile1 did not exist: new to be created
363-InnoDB: Setting log file ./ib_logfile1 size to <SIZE> MB
364-InnoDB: Database physically writes the file full: wait...
365-101107 16:54:15 InnoDB: Shutdown completed; log sequence number 1284108
366-
367-.fi
368-.SH " Restoring a Backup "
369-
370-
371-The xtrabackup binary does not have any functionality for restoring a backup. That is up to the user to do. You might use
372-.B "rsync"
373-or
374-.B "cp"
375-to restore the files. You should check that the restored files have the correct ownership and permissions.
376-
377-Note that xtrabackup backs up only the InnoDB data. You must separately restore the MySQL system database, MyISAM data, table definition files (.frm files), and everything else necessary to make your database functional.
378-
379-.SH " How-To and Recipes "
380-
381-
382-This page is a quick-reference list of recipes for the
383-.B "xtrabackup"
384-tool. It doesn't mention the
385-.B "innobackupex"
386-tool; that is documented separately.
387-
388-In all of the below examples, we assume the following:
389-
390-.HP
391-* You are backing up a server whose data is stored in
392-.B "/var/lib/mysql/"
393-, which is the standard location for most distributions
394-.HP
395-* You are storing the backups in
396-.B "/data/backups/mysql"
397-
398-.HP
399-* You have a
400-.B "my.cnf"
401-file in a standard location, such as
402-.B "/etc/my.cnf"
403-, with at least the following contents:
404-.nf
405-[mysqld]
406-datadir=/var/lib/mysql/
407-[xtrabackup]
408-target_dir=/data/backups/mysql/
409-
410-.fi
411-
412-.SS " Making a Backup "
413-
414-
415-Making the backup copies the InnoDB data and log files to the destination. Preparing the backup makes the data files consistent and ready to use.
416-
417-.HP
418-* Make a backup:
419-.nf
420-xtrabackup --backup
421-.fi
422-.HP
423-* Prepare the backup:
424-.nf
425-xtrabackup --prepare
426-.fi
427-.HP
428-* Prepare again, to create fresh InnoDB log files:
429-.nf
430-xtrabackup --prepare
431-.fi
432-
433-
434-.B "Success Criterion"
435-
436-
437-.HP
438-* The exit status of
439-.B "xtrabackup"
440-is 0.
441-.HP
442-* In the second
443-.B "--prepare"
444-step, you should see InnoDB print messages similar to "Log file ./ib_logfile0 did not exist: new to be created", followed by a line indicating the log file was created.
445-
446-
447-.B "Relevant Configuration"
448-
449-
450-.HP
451-* You might want to set the
452-.B "--use-memory"
453-option to something similar to the size of your buffer pool, if you are on a dedicated server that has enough free memory.
454-
455-.SS " Making an Incremental Backup "
456-
457-
458-Making an incremental backup requires a full backup as a base.
459-
460-.HP
461-* Create a full backup as above, but do not run the
462-.B "--prepare"
463-command yet
464-.HP
465-* Suppose the full backup is on Monday
466-.HP
467-* Create an incremental backup on Tuesday:
468-.nf
469-
470- xtrabackup --backup --target-dir=/data/backups/inc/tue/ \
471- --incremental-basedir=/data/backups/mysql/
472-.fi
473-.HP
474-* Create an incremental backup on Wednesday:
475-.nf
476-
477- xtrabackup --backup --target-dir=/data/backups/inc/wed/ \
478- --incremental-basedir=/data/backups/inc/tue/
479-.fi
480-.HP
481-* Prepare the base backup from Monday:
482-.nf
483-
484- xtrabackup --prepare --apply-log-only --target-dir=/data/backups/mysql/
485-.fi
486-.HP
487-* Roll Monday's data forward to the state on Tuesday:
488-.nf
489-
490- xtrabackup --prepare --apply-log-only --target-dir=/data/backups/mysql/ \
491- --incremental-dir=/data/backups/inc/tue/
492-.fi
493-.HP
494-* Roll forward again to the state on Wednesday:
495-.nf
496-
497- xtrabackup --prepare --apply-log-only --target-dir=/data/backups/mysql/ \
498- --incremental-dir=/data/backups/inc/wed/
499-.fi
500-.HP
501-* Follow the steps for a normal backup to complete the preparation stage so the backup is ready to restore
502-
503-.SS " Restoring the Backup "
504-
505-
506-Because
507-.B "xtrabackup"
508-doesn't copy MyISAM files, .frm files, and the rest of the database, you might need to back those up separately. To restore the InnoDB data, simply do something like the following after preparing:
509-
510-
511-.nf
512-
513-cd /data/backups/mysql/
514-rsync -rvt --exclude 'xtrabackup_checkpoints' --exclude 'xtrabackup_logfile' \
515- ./ /var/lib/mysql
516-chown -R mysql:mysql /var/lib/mysql/
517-
518-.fi
519-.SH " Limitations of xtrabackup "
520-
521-
522-The xtrabackup binary has some limitations you should be aware of to ensure that your backups go smoothly and are recoverable.
523-
524-.HP
525-* If the xtrabackup_logfile is larger than 4GB, the
526-.B "--prepare"
527-step will fail on 32-bit versions of xtrabackup. This limitation also applied to some older 64-bit versions of xtrabackup (
528-.B FIXME
529-what versions?).
530-.HP
531-* xtrabackup does not currently create new InnoDB log files (ib_logfile0, etc) during the initial
532-.B "--prepare"
533-step. You must prepare the backup a second time to do this, if you wish.
534-.HP
535-* xtrabackup copies only the InnoDB data and logs. It does not copy table definition files (.frm files), MyISAM data, users, privileges, or any other portions of the overall database that lie outside of the InnoDB data. To back up this data, you need a wrapper script such as
536-.B "innobackupex"
537-.
538-.HP
539-*
540-.B "xtrabackup"
541-doesn't understand the very old
542-.B "--set-variable"
543-
544-.B "my.cnf"
545-syntax that MySQL uses. See
546-.B "configuration"
547-.
548-.SH " Configuring xtrabackup "
549-
550-
551-This page explains how to configure
552-.B "xtrabackup"
553-and how to configure your system to support
554-.B "xtrabackup"
555-correctly.
556-
557-.SS " Configuring xtrabackup "
558-
559-
560-All of the
561-.B "xtrabackup"
562-configuration is through options, which behave exactly like standard MySQL program options: they can be specified either at the command-line, or through a file such as /etc/my.cnf.
563-
564-The xtrabackup binary reads the [myslqd] and [xtrabackup] sections from any configuration files, in order. That is so that it can read its options from your existing MySQL installation, such as the
565-.B "datadir"
566-or some of the InnoDB options. If you want to override these, just specify them in the [xtrabackup] section, and because it is read later, it will take precedence.
567-
568-You don't need to put any configuration in your my.cnf if you don't want to. You can simply specify the options on the command-line. Normally, the only thing you might find convenient to place in the [xtrabackup] section of your my.cnf file is the
569-.B "target_dir"
570-option, for example,
571-
572-
573-.nf
574-
575-[xtrabackup]
576-target_dir = /data/backups/mysql/
577-
578-.fi
579-
580-This manual will assume that you
581-.B "do not"
582-have any file-based configuration for
583-.B "xtrabackup"
584-, so it will always show command-line options being used explicitly. Please see the
585-.B "option and variable reference"
586-for details on all of the configuration options.
587-
588-The
589-.B "xtrabackup"
590-binary does not accept exactly the same syntax in the
591-.B "my.cnf"
592-file as the
593-.B "mysqld"
594-server binary does. For historical reasons, the
595-.B "mysqld"
596-server binary accepts parameters with a
597-.B "--set-variable=<variable>=<value>"
598-syntax, which
599-.B "xtrabackup"
600-does not understand. If your
601-.B "my.cnf"
602-file has such configuration directives, you should rewrite them in the
603-.B "--variable=value"
604-syntax.
605-
606-.SS " System Configuration and NFS Volumes "
607-
608-
609-The
610-.B "xtrabackup"
611-tool requires no special configuration on most systems. However, the storage where the
612-.B "--target-dir"
613-is located must behave properly when
614-.B "fsync()"
615-is called. In particular, we have noticed that NFS volumes not mounted with the
616-.B "sync"
617-option might not really sync the data. As a result, if you back up to an NFS volume mounted with the
618-.B "async"
619-option, and then try to prepare the backup from a different server that also mounts that volume, the data might appear to be corrupt. You can use the
620-.B "noasync"
621-mount option to avoid this problem.
622-.SH " The xtrabackup Option Reference "
623-
624-
625-This page documents all of the command-line options for the
626-.B "xtrabackup"
627-binary.
628-
629-.SS " --print-defaults "
630-
631-
632-Print the program argument list and exit. Must be given as the first option on the command-line.
633-
634-.SS " --no-defaults "
635-
636-
637-Don't read default options from any option file. Must be given as the first option on the command-line.
638-
639-.SS " --defaults-file "
640-
641-
642-Only read default options from the given file. Must be given as the first option on the command-line. Must be a real file; cannot be a symbolic link.
643-
644-.SS " --defaults-extra-file "
645-
646-
647-Read this file after the global files are read. Must be given as the first option on the command-line.
648-
649-.SS " --apply-log-only "
650-
651-
652-This option causes only the redo stage to be performed when
653-.B "incremental backups"
654-.
655-
656-.SS " --backup "
657-
658-
659-Make a backup and place it in
660-.B "--target-dir"
661-. See
662-.B "creating a backup"
663-.
664-
665-.SS " --create-ib-logfile "
666-
667-
668-This option is not currently implemented. To create the InnoDB log files, you must
669-.B "prepare the backup"
670-twice at present.
671-
672-.SS " --datadir "
673-
674-
675-The source directory for the backup. This should be the same as the datadir for your MySQL server, so it should be read from
676-.B "my.cnf"
677-if that exists; otherwise you must specify it on the command line.
678-
679-.SS " --export "
680-
681-
682-Create files necessary for exporting tables. See [[export and import]].
683-
684-.SS " --incremental-basedir "
685-
686-
687-When creating an
688-.B "incremental backup"
689-, this is the directory containing the full backup that is the base dataset for the incremental backups.
690-
691-.SS " --incremental-dir "
692-
693-
694-When preparing an
695-.B "incremental backup"
696-, this is the directory where the incremental backup is combined with the full backup to make a new full backup.
697-
698-.SS " --incremental-lsn "
699-
700-
701-When creating an
702-.B "incremental backup"
703-, you can specify the log sequence number (LSN) in high:low format as two 32-bit integers instead of specifying
704-.B "--incremental-basedir"
705-.
706-
707-.SS " --innodb-miscellaneous "
708-
709-
710-There is a large group of InnoDB options that are normally read from the
711-.B "my.cnf"
712-configuration file, so that
713-.B "xtrabackup"
714-boots up its embedded InnoDB in the same configuration as your current server. You normally do not need to specify these explicitly. These options have the same behavior that they have in InnoDB or XtraDB. They are as follows:
715-
716-.HP
717-*
718-.B "--innodb-adaptive-hash-index"
719-
720-.HP
721-*
722-.B "--innodb-additional-mem-pool-size"
723-
724-.HP
725-*
726-.B "--innodb-autoextend-increment"
727-
728-.HP
729-*
730-.B "--innodb-buffer-pool-size"
731-
732-.HP
733-*
734-.B "--innodb-checksums"
735-
736-.HP
737-*
738-.B "--innodb-data-file-path"
739-
740-.HP
741-*
742-.B "--innodb-data-home-dir"
743-
744-.HP
745-*
746-.B "--innodb-doublewrite-file"
747-
748-.HP
749-*
750-.B "--innodb-doublewrite"
751-
752-.HP
753-*
754-.B "--innodb-extra-undoslots"
755-
756-.HP
757-*
758-.B "--innodb-fast-checksum"
759-
760-.HP
761-*
762-.B "--innodb-file-io-threads"
763-
764-.HP
765-*
766-.B "--innodb-file-per-table"
767-
768-.HP
769-*
770-.B "--innodb-flush-log-at-trx-commit"
771-
772-.HP
773-*
774-.B "--innodb-flush-method"
775-
776-.HP
777-*
778-.B "--innodb-force-recovery"
779-
780-.HP
781-*
782-.B "--innodb-io-capacity"
783-
784-.HP
785-*
786-.B "--innodb-lock-wait-timeout"
787-
788-.HP
789-*
790-.B "--innodb-log-buffer-size"
791-
792-.HP
793-*
794-.B "--innodb-log-files-in-group"
795-
796-.HP
797-*
798-.B "--innodb-log-file-size"
799-
800-.HP
801-*
802-.B "--innodb-log-group-home-dir"
803-
804-.HP
805-*
806-.B "--innodb-max-dirty-pages-pct"
807-
808-.HP
809-*
810-.B "--innodb-open-files"
811-
812-.HP
813-*
814-.B "--innodb-page-size"
815-
816-.HP
817-*
818-.B "--innodb-read-io-threads"
819-
820-.HP
821-*
822-.B "--innodb-write-io-threads"
823-
824-
825-.SS " --log-stream "
826-
827-
828-Makes
829-.B "xtrabackup"
830-not copy data files, and output the contents of the InnoDB log files to STDOUT until the
831-.B "--suspend-at-end"
832-automatically.
833-
834-.SS " --prepare "
835-
836-
837-Makes
838-.B "xtrabackup"
839-perform recovery on a backup created with
840-.B "--backup"
841-, so that it is ready to use. See
842-.B "preparing a backup"
843-.
844-
845-.SS " --print-param "
846-
847-
848-Makes
849-.B "xtrabackup"
850-print out parameters that can be used for copying the data files back to their original locations to restore them. See
851-.B "scripting with xtrabackup"
852-.
853-
854-.SS " --stats "
855-
856-
857-Causes
858-.B "xtrabackup"
859-to scan the specified data files and print out
860-.B "index statistics"
861-.
862-
863-.SS " --suspend-at-end "
864-
865-
866-Causes
867-.B "xtrabackup"
868-to create a file called
869-.B "xtrabackup_suspended"
870-in the
871-.B "scripting with xtrabackup"
872-.
873-
874-.SS " --tables-file "
875-
876-
877-A file containing one table name per line, in
878-.B "databasename.tablename"
879-format. The backup will be limited to the specified tables. See
880-.B "partial backups"
881-.
882-
883-.SS " --tables "
884-
885-
886-A regular expression against which the full tablename, in
887-.B "databasename.tablename"
888-format, is matched. If the name matches, the table is backed up. See
889-.B "partial backups"
890-.
891-
892-.SS " --target-dir "
893-
894-
895-This option specifies the destination directory for the backup. If the directory does not exist,
896-.B "xtrabackup"
897-creates it. If the directory does exist and is empty,
898-.B "xtrabackup"
899-will succeed.
900-.B "xtrabackup"
901-will not overwrite existing files, however; it will fail with operating system error 17, 'file exists.'
902-
903-Note that for
904-.B "--prepare"
905-, relative paths are interpreted as being relative to the current working directory.
906-
907-.SS " --throttle "
908-
909-
910-This option limits
911-.B "throttling a backup"
912-.
913-
914-.SS " --tmpdir "
915-
916-
917-This option is currently not used for anything except printing out the correct
918-.B "tmpdir"
919-parameter when
920-.B "--print-param"
921-is used.
922-
923-.SS " --use-memory "
924-
925-
926-This option affects how much memory is allocated for
927-.B "--stats"
928-. Its purpose is similar to
929-.B "innodb_buffer_pool_size"
930-. It does not do the same thing as the similarly named option in Oracle's InnoDB Hot Backup tool. The default value is 100MB, and if you have enough available memory, 1GB to 2GB is a good recommended value.
931-
932-.SS " --parallel "
933-
934-
935-This option specifies the number of threads to use to copy multiple data files concurrently when creating a backup. The default value is 1 (i.e., no concurrent transfer).
936-
937-Currently, the option only works for local backups.
938-
939-.SH " Exporting and Importing Tables "
940-
941-
942-In standard InnoDB, it is not normally possible to copy tables between servers by copying the files, even with
943-.B "innodb_file_per_table"
944-. However, with the xtrabackup binary, you can export individual tables from any InnoDB database, and import them into Percona Server with XtraDB. (The source doesn't have to be XtraDB, but the destination does.) This functionality requires
945-.B "innodb_file_per_table"
946-to be used on both servers, and requires
947-.B "innodb_expand_import"
948-to be enabled on the destination server. It only works on individual
949-.B ".ibd"
950-files, and cannot export a table that is not contained in its own
951-.B ".ibd"
952-file.
953-
954-Let's see how to export and import the following table:
955-
956-
957-.nf
958-
959-CREATE TABLE export_test (
960- a int(11) DEFAULT NULL
961-) ENGINE=InnoDB DEFAULT CHARSET=latin1;
962-
963-.fi
964-
965-.SS " Exporting the Table "
966-
967-
968-This table should have been created in innodb_file_per_table mode, so after taking a backup as usual with
969-.B "--backup"
970-, the
971-.B ".ibd"
972-file should exist in the target directory:
973-
974-
975-.nf
976-
977-$ find /data/backups/mysql/ -name export_test.*
978-/data/backups/mysql/test/export_test.ibd
979-
980-.fi
981-
982-when you prepare the backup, add the extra parameter
983-.B "--export"
984-to the command. If you do not have
985-.B "innodb_file_per_table"
986-in your my.cnf, you must add that to the command-line options. Here is an example:
987-
988-
989-.nf
990-
991-xtrabackup --prepare --export --innodb-file-per-table --target-dir=/data/backups/mysql/
992-
993-.fi
994-
995-Now you should see a
996-.B ".exp"
997-file in the target directory:
998-
999-
1000-.nf
1001-
1002-$ find /data/backups/mysql/ -name export_test.*
1003-/data/backups/mysql/test/export_test.exp
1004-/data/backups/mysql/test/export_test.ibd
1005-
1006-.fi
1007-
1008-These two files are all you need to import the table into a server running Percona Server with XtraDB.
1009-
1010-.SS " Importing the Table "
1011-
1012-
1013-On the destination server running Percona Server with XtraDB, with
1014-.B "innodb_expand_import"
1015-enabled, create a table with the same structure, and then perform the following steps:
1016-
1017- - Execute
1018-.B "ALTER TABLE test.export_test DISCARD TABLESPACE;"
1019-
1020- - If you see the following message, then you must enable innodb_file_per_table and create the table again: "ERROR 1030 (HY000): Got error -1 from storage engine"
1021- - Copy the exported files to the
1022-.B "test/"
1023-subdirectory of the destination server's data directory
1024- - Execute
1025-.B "ALTER TABLE test.export_test IMPORT TABLESPACE;"
1026-
1027-
1028-The table should now be imported, and you should be able to SELECT from it and see the imported data.
1029-
1030-.SH " Incremental Backups "
1031-
1032-
1033-The
1034-.B "xtrabackup"
1035-tool supports incremental backups, which means that it can copy only the data that has changed since the last full backup. You can perform many incremental backups between each full backup, so you can set up a backup process such as a full backup once a week and an incremental backup every day, or full backups every day and incremental backups every hour.
1036-
1037-Incremental backups work because each InnoDB page (usually 16kb in size) contains a
1038-.I "log sequence number"
1039-, or LSN. The LSN is the system version number for the entire database. Each page's LSN shows how recently it was changed. An incremental backup copies each page whose LSN is newer than the previous incremental or full backup's LSN.
1040-
1041-Incremental backups do not actually compare the data files to the previous backup's data files. In fact, you can use
1042-.B "--incremental-lsn"
1043-to perform an incremental backup without even having the previous backup, if you know its LSN. Incremental backups simply read the pages and compare their LSN to the last backup's LSN. You still need a full backup to recover the incremental changes, however; without a full backup to act as a base, the incremental backups are useless.
1044-
1045-.SS " Creating an Incremental Backup "
1046-
1047-
1048-To make an incremental backup, begin with a full backup as usual. The xtrabackup binary writes a file called xtrabackup_checkpoints into the backup's target directory. This file contains a line showing the
1049-.B "to_lsn"
1050-, which is the database's LSN at the end of the backup. Create the full backup with a command such as the following:
1051-
1052-
1053-.nf
1054-
1055-xtrabackup --backup --target-dir=/data/backups/base --datadir=/var/lib/mysql/
1056-
1057-.fi
1058-
1059-
1060-.B "TIP:"
1061-If you want a
1062-.B "usable"
1063-full backup, use innobackupex since xtrabackup itself won't copy table definitions, triggers, or anything else that's not .ibd.
1064-
1065-
1066-If you look at the xtrabackup_checkpoints file, you should see some contents similar to the following:
1067-
1068-
1069-.nf
1070-
1071-backup_type = full-backuped
1072-from_lsn = 0
1073-to_lsn = 1291135
1074-
1075-.fi
1076-
1077-Now that you have a full backup, you can make an incremental backup based on it. Use a command such as the following:
1078-
1079-
1080-.nf
1081-
1082-xtrabackup --backup --target-dir=/data/backups/inc1 \
1083- --incremental-basedir=/data/backups/base --datadir=/var/lib/mysql/
1084-
1085-.fi
1086-
1087-The
1088-.B "/data/backups/inc1/"
1089-directory should now contain delta files, such as
1090-.B "ibdata1.delta"
1091-and
1092-.B "test/table1.ibd.delta"
1093-. These represent the changes since the LSN 1291135. If you examine the
1094-.B "xtrabackup_checkpoints"
1095-file in this directory, you should see something similar to the following:
1096-
1097-
1098-.nf
1099-
1100-backup_type = incremental
1101-from_lsn = 1291135
1102-to_lsn = 1291340
1103-
1104-.fi
1105-
1106-The meaning should be self-evident. It's now possible to use this directory as the base for yet another incremental backup:
1107-
1108-
1109-.nf
1110-
1111-xtrabackup --backup --target-dir=/data/backups/inc2 \
1112- --incremental-basedir=/data/backups/inc1 --datadir=/var/lib/mysql/
1113-
1114-.fi
1115-
1116-.SS " Preparing the Backups "
1117-
1118-
1119-The
1120-.B "--prepare"
1121-step for incremental backups is not the same as for normal backups. In normal backups, two types of operations are performed to make the database consistent: committed transactions are replayed from the log file against the data files, and uncommitted transactions are rolled back. For technical reasons, you must skip the rollback of uncommitted transactions when preparing a backup that will be used as the base for an incremental backup. You should use the
1122-.B "--apply-log-only"
1123-option to prevent the rollback phase.
1124-
1125-
1126-.B "WARNING:"
1127-If you do not use the
1128-.B "--apply-log-only"
1129-option to prevent the rollback phase, then your incremental backups will be useless. After transactions have been rolled back, further incremental backups cannot be applied.
1130-
1131-
1132-Beginning with the full backup you created, you can prepare it, and then apply the incremental differences to it. Recall that you have the following backups:
1133-
1134-
1135-.nf
1136-
1137-/data/backups/base
1138-/data/backups/inc1
1139-/data/backups/inc2
1140-
1141-.fi
1142-
1143-To prepare the base backup, you need to run
1144-.B "--prepare"
1145-as usual, but prevent the rollback phase:
1146-
1147-
1148-.nf
1149-
1150-xtrabackup --prepare --apply-log-only --target-dir=/data/backups/base
1151-
1152-.fi
1153-
1154-The output should end with some text such as the following:
1155-
1156- 101107 20:49:43 InnoDB: Shutdown completed; log sequence number 1291135
1157-
1158-The log sequence number should match the to_lsn of the base backup, which you saw previously.
1159-
1160-This backup is actually safe to restore as-is now, even though the rollback phase has been skipped. If you restore it and start MySQL, InnoDB will detect that the rollback phase was not performed, and it will do that in the background, as it usually does for a crash recovery upon start. It will notify you that the database was not shut down normally, but the recovery phase should be nearly instantaneous, because the redo log has already been applied to the data files.
1161-
1162-To apply the first incremental backup to the full backup, you should use the following command:
1163-
1164-
1165-.nf
1166-
1167-xtrabackup --prepare --apply-log-only --target-dir=/data/backups/base \
1168- --incremental-dir=/data/backups/inc1
1169-
1170-.fi
1171-
1172-This applies the delta files to the files in /data/backups/base, which rolls them forward in time to the time of the incremental backup. It then applies the redo log as usual to the result. The final data is in /data/backups/base,
1173-.B "not"
1174-in the incremental directory. You should see some output such as the following:
1175-
1176-
1177-.nf
1178-
1179-incremental backup from 1291135 is enabled.
1180-xtrabackup: cd to /data/backups/base/
1181-xtrabackup: This target seems to be already prepared.
1182-xtrabackup: xtrabackup_logfile detected: size=2097152, start_lsn=(1291340)
1183-Applying /data/backups/inc1/ibdata1.delta ...
1184-Applying /data/backups/inc1/test/table1.ibd.delta ...
1185-.... snip
1186-101107 20:56:30 InnoDB: Shutdown completed; log sequence number 1291340
1187-
1188-.fi
1189-
1190-Again, the LSN should match what you saw from your earlier inspection of the first incremental backup. If you restore the files from /data/backups/base, you should see the state of the database as of the first incremental backup.
1191-
1192-Preparing the second incremental backup is a similar process: apply the deltas to the (modified) base backup, and you will roll its data forward in time to the point of the second incremental backup:
1193-
1194-
1195-.nf
1196-
1197-xtrabackup --prepare --apply-log-only --target-dir=/data/backups/base \
1198- --incremental-dir=/data/backups/inc2
1199-
1200-.fi
1201-
1202-If you wish to avoid the notice that InnoDB was not shut down normally, when you have applied the desired deltas to the base backup, you can run
1203-.B "--prepare"
1204-again without disabling the rollback phase.
1205-.SH " Partial Backups "
1206-
1207-
1208-xtrabackup supports taking partial backups when
1209-.B "innodb_file_per_table"
1210-is enabled. There are two ways to create partial backups.
1211-
1212-For the purposes of this manual page, we will assume that there is a database named 'test' which contains tables named 't1' and 't2'.
1213-
1214-.SS " Using the --tables Option "
1215-
1216-
1217-The first method is with the
1218-.B "--tables"
1219-option. The option's value is a regular expression that is matched against the fully qualified tablename, including the database name, in the form
1220-.B "databasename.tablename"
1221-.
1222-
1223-To back up only tables in the 'test' database, you can use the following command:
1224-
1225- xtrabackup --backup --datadir=/var/lib/mysql --target-dir=/data/backups/ \
1226- --tables="^test[.].*"
1227-
1228-To back up only the table 'test.t1', you can use the following command:
1229-
1230- xtrabackup --backup --datadir=/var/lib/mysql --target-dir=/data/backups/ \
1231- --tables="^test[.]t1"
1232-
1233-.SS " Using the --tables-file Option "
1234-
1235-
1236-The
1237-.B "--tables-file"
1238-option specifies a file that can contain multiple table names, one table name per line in the file. Only the tables named in the file will be backed up. Names are matched exactly, case-sensitive, with no pattern or regular expression matching. The table names must be fully qualified, in
1239-.B "databasename.tablename"
1240-format.
1241-
1242-.SS " Preparing the Backup "
1243-
1244-
1245-When you use the
1246-.B "--prepare"
1247-option on a partial backup, you will see warnings about tables that don't exist. That is because these tables exist in the data dictionary inside InnoDB, but the corresponding
1248-.B ".ibd"
1249-files don't exist. They were not copied into the backup directory. These tables will be removed from the data dictionary, and when you restore the backup and start InnoDB, they will no longer exist and will not cause any errors or warnings to be printed to the log file.
1250-
1251-An example of the error message you will see during the prepare phase follows.
1252-
1253-
1254-.nf
1255-
1256-InnoDB: Reading tablespace information from the .ibd files...
1257-101107 22:31:30 InnoDB: Error: table 'test1/t'
1258-InnoDB: in InnoDB data dictionary has tablespace id 6,
1259-InnoDB: but tablespace with that id or name does not exist. It will be removed from data dictionary.
1260-
1261-.fi
1262-
1263-.SH " Analyzing Table Statistics "
1264-
1265-
1266-The
1267-.B "xtrabackup"
1268-binary can analyze InnoDB data files in read-only mode to give statistics about them. To do this, you should use the
1269-.B "--stats"
1270-option. You can combine this with the
1271-.B "--tables"
1272-option to limit the files to examine. It also uses the
1273-.B "--use-memory="
1274-option.
1275-
1276-You can perform the analysis on a running server, with some chance of errors due to the data being changed during analysis. Or, you can analyze a backup copy of the database. Either way, to use the statistics feature, you need a clean copy of the database including correctly sized log files, so you need to execute with
1277-.B "--prepare"
1278-twice to use this functionality on a backup.
1279-
1280-The result of running on a backup might look like the following:
1281-
1282-
1283-.nf
1284-
1285-<INDEX STATISTICS>
1286- table: test/table1, index: PRIMARY, space id: 12, root page 3
1287- estimated statistics in dictionary:
1288- key vals: 25265338, leaf pages 497839, size pages 498304
1289- real statistics:
1290- level 2 pages: pages=1, data=5395 bytes, data/pages=32%
1291- level 1 pages: pages=415, data=6471907 bytes, data/pages=95%
1292- leaf pages: recs=25958413, pages=497839, data=7492026403 bytes, data/pages=91%
1293-
1294-.fi
1295-
1296-This can be interpreted as follows:
1297-
1298-.HP
1299-* The first line simply shows the table and index name and its internal identifiers. If you see an index named
1300-.B "GEN_CLUST_INDEX"
1301-, that is the table's clustered index, automatically created because you did not explicitly create a PRIMARY KEY.
1302-.HP
1303-* The
1304-.I "estimated statistics in dictionary"
1305-information is similar to the data that's gathered through
1306-.B "ANALYZE TABLE"
1307-inside of InnoDB to be stored as estimated cardinality statistics and passed to the query optimizer
1308-.HP
1309-* The
1310-.I "real statistics"
1311-information is the result of scanning the data pages and computing exact information about the index.
1312-.HP
1313-* The
1314-.B "level <X> pages:"
1315-output means that the line shows information about pages at that level in the index tree. The larger <X> is, the farther it is from the leaf pages, which are level 0. The first line is the root page.
1316-.HP
1317-* The
1318-.B "leaf pages"
1319-output shows the leaf pages, of course. This is where the table's data is stored.
1320-.HP
1321-* The
1322-.B "external pages:"
1323-output (not shown) shows large external pages that hold values too long to fit in the row itself, such as long BLOB and TEXT values.
1324-.HP
1325-* The
1326-.I "recs"
1327-is the real number of records (rows) in leaf pages.
1328-.HP
1329-* The
1330-.I "pages"
1331-is the page count.
1332-.HP
1333-* The
1334-.I "data"
1335-is the total size of the data in the pages, in bytes.
1336-.HP
1337-* The
1338-.I "data/pages"
1339-is calculated as (data / (pages * PAGE_SIZE)) * 100%. It will never reach 100% because of space reserved for page headers and footers.
1340-
1341-
1342-.SH " Throttling Backups "
1343-
1344-
1345-Although
1346-.B "xtrabackup"
1347-does not block your database's operation, any backup can add load to the system being backed up. On systems that do not have much spare I/O capacity, it might be helpful to throttle the rate at which
1348-.B "xtrabackup"
1349-reads and writes data. You can do this with the
1350-.B "--throttle"
1351-option.
1352-
1353-In
1354-.B "--backup"
1355-mode, this option limits the number of pairs of read-and-write operations per second that
1356-.B "xtrabackup"
1357-will perform. If you are creating an
1358-.B "incremental backup"
1359-, then the limit is the number of read IO operations per second.
1360-
1361-By default, there is no throttling, and
1362-.B "xtrabackup"
1363-reads and writes data as quickly as it can. If you set too strict of a limit on the I/O operations, the backup might be so slow that it will never catch up with the transaction logs that InnoDB is writing, so the backup might never complete.
1364-
1365-.SH " Working with Binary Logs "
1366-
1367-
1368-The
1369-.B "xtrabackup"
1370-binary integrates with information that InnoDB stores in its transaction log about the corresponding binary log position for committed transactions. This enables it to print out the binary log position to which a backup corresponds, so you can use it to set up new replication slaves or perform point-in-time recovery.
1371-
1372-.SS " Finding the Binary Log Position "
1373-
1374-
1375-You can find the binary log position corresponding to a backup performing the
1376-.B "--prepare"
1377-process. If your backup is from a server with binary logging enabled,
1378-.B "xtrabackup"
1379-will create a file named
1380-.B "xtrabackup_binlog_pos_innodb"
1381-in the target directory. This file contains the binary log file name and position of the exact point in the binary log to which the prepared backup corresponds.
1382-
1383-You will also see output similar to the following during the prepare stage:
1384-
1385-
1386-.nf
1387-
1388-InnoDB: Last MySQL binlog file position 0 3252710, file name ./mysql-bin.000001
1389-... snip ...
1390-[notice (again)]
1391- If you use binary log and don't use any hack of group commit,
1392- the binary log position seems to be:
1393-InnoDB: Last MySQL binlog file position 0 3252710, file name ./mysql-bin.000001
1394-
1395-.fi
1396-
1397-The output should contain the same file name and position as the
1398-.B "xtrabackup_binlog_pos_innodb"
1399-file. The message about hacking group commit refers to an early implementation of emulated group commit in Percona Server.
1400-.B FIXME
1401-is this still uncertain, or do we know that it works correctly now?
1402-
1403-.SS " Point-In-Time Recovery "
1404-
1405-
1406-To perform a point-in-time recovery from an
1407-.B "xtrabackup"
1408-backup, you should prepare and restore the backup, and then replay binary logs from the point shown in the
1409-.B "xtrabackup_binlog_pos_innodb"
1410-file.
1411-
1412-.SS " Setting Up a New Replication Slave "
1413-
1414-
1415-To set up a new replica, you should prepare the backup, and restore it to the data directory of your new replication slave. Then in your
1416-.B "CHANGE MASTER TO"
1417-command, use the binary log filename and position shown in the
1418-.B "xtrabackup_binlog_pos_innodb"
1419-file to start replication.
1420-
1421-.SH " Scripting Backups With xtrabackup "
1422-
1423-
1424-The
1425-.B "xtrabackup"
1426-tool has several features to enable scripts to control it while they perform related tasks. The
1427-.B "innobackupex"
1428-script is one example, but xtrabackup is easy to control with your own command-line scripts too.
1429-
1430-.SS " Suspending After Copying "
1431-
1432-
1433-In
1434-.B "backup"
1435-mode, xtrabackup normally copies the log files in a background thread, copies the data files in a foreground thread, and then stops the log copying thread and finishes. If you use the
1436-.B "--suspend-at-end"
1437-option, instead of stopping the log thread and finishing, xtrabackup continues to copy the log files, and creates a file in the target directory called
1438-.B "xtrabackup_suspended"
1439-. As long as that file exists,
1440-.B "xtrabackup"
1441-will continue to watch the log files and copy them into the
1442-.B "xtrabackup_logfile"
1443-in the target directory. When the file is removed,
1444-.B "xtrabackup"
1445-will finish copying the log file and exit.
1446-
1447-This functionality is useful for coordinating the InnoDB data backups with other actions. Perhaps the most obvious is copying the table definitions (the .frm files) so that the backup can be restored. You can start
1448-.B "xtrabackup"
1449-in the background, wait for the
1450-.B "xtrabackup_suspended"
1451-file to be created, and then copy any other files you need to complete the backup. This is exactly what the
1452-.B "innobackupex"
1453-tool does (it also copies MyISAM data and other files).
1454-
1455-.SS " Generating Meta-Data "
1456-
1457-
1458-It is a good idea for the backup to include all the information you need to restore the backup. The
1459-.B "xtrabackup"
1460-tool can print out the contents of a
1461-.B "my.cnf"
1462-file that are needed to restore the data and log files. If you add the
1463-.B "--print-param"
1464-option, it will print out something like the following:
1465-
1466-
1467-.nf
1468-
1469-# This MySQL options file was generated by XtraBackup.
1470-[mysqld]
1471-datadir = /data/mysql/
1472-innodb_data_home_dir = /data/innodb/
1473-innodb_data_file_path = ibdata1:10M:autoextend
1474-innodb_log_group_home_dir = /data/innodb-logs/
1475-
1476-.fi
1477-
1478-You can redirect this output into a file in the target directory of the backup.
1479-
1480-.SS " Agreeing on the Source Directory "
1481-
1482-
1483-It's possible that the presence of a defaults file or other factors could cause
1484-.B "xtrabackup"
1485-to back up data from a different location than you expected. To prevent this, you can use
1486-.B "--print-param"
1487-to ask it where it will be copying data from. You can use the output to ensure that
1488-.B "xtrabackup"
1489-and your script are working on the same dataset.
1490-
1491-.SH " XtraBackup Exit Codes "
1492-
1493-
1494-The
1495-.B "xtrabackup"
1496-binary exits with the traditional success value of 0 after a backup when no error occurs. If an error occurs during the backup, the exit value is 1.
1497-
1498-In certain cases, the exit value can be something other than 0 or 1, due to the command-line option code included from the MySQL libraries. An unknown command-line option, for example, will cause an exit code of 255.
1499-
1500-When an error happens in the
1501-.B "main()"
1502-function of
1503-.B "xtrabackup.c"
1504-, when
1505-.B "xtrabackup"
1506-is preparing to perform the backup, the exit code is -1. This is usually because of a missing or wrong command-line option, failure to open a file or directory that the user specified as a command-line option, or similar. This behavior is changed in xtrabackup 1.4 and later, so it always returns 0 or 1. (However, the MySQL libraries might still exit with a code of 255.)
1507-
1508-.SH " Implementation Details "
1509-
1510-
1511-This page contains notes on various internal aspects of the
1512-.B "xtrabackup"
1513-tool's operation.
1514-
1515-.SS " File Permissions "
1516-
1517-
1518-
1519-.B "xtrabackup"
1520-opens the source data files in read-write mode, although it does not modify the files. This means that you must run
1521-.B "xtrabackup"
1522-as a user who has permission to write the data files. The reason for opening the files in read-write mode is that
1523-.B "xtrabackup"
1524-uses the embedded InnoDB libraries to open and read the files, and InnoDB opens them in read-write mode because it normally assumes it is going to write to them.
1525-
1526-.SS " Tuning the OS Buffers "
1527-
1528-
1529-Because
1530-.B "xtrabackup"
1531-reads large amounts of data from the filesystem, it uses
1532-.B "posix_fadvise()"
1533-where possible, to instruct the operating system not to try to cache the blocks it reads from disk. Without this hint, the operating system would prefer to cache the blocks, assuming that
1534-.B "xtrabackup"
1535-is likely to need them again, which is not the case. Caching such large files can place pressure on the operating system's virtual memory and cause other processes, such as the database server, to be swapped out. The
1536-.B "xtrabackup"
1537-tool avoids this with the following hint on both the source and destination files:
1538-
1539- posix_fadvise(file, 0, 0, POSIX_FADV_DONTNEED)
1540-
1541-In addition,
1542-.B "xtrabackup"
1543-asks the operating system to perform more aggressive read-ahead optimizations on the source files:
1544-
1545- posix_fadvise(file, 0, 0, POSIX_FADV_SEQUENTIAL)
1546-
1547-.SS " Copying Data Files "
1548-
1549-
1550-When copying the data files to the target directory,
1551-.B "xtrabackup"
1552-reads and writes 1MB of data at a time. This is not configurable. When copying the log file,
1553-.B "xtrabackup"
1554-reads and writes 512 bytes at a time. This is also not possible to configure, and matches InnoDB's behavior.
1555-
1556-After reading from the files,
1557-.B "xtrabackup"
1558-iterates over the 1MB buffer a page at a time, and checks for page corruption on each page with InnoDB's
1559-.B "buf_page_is_corrupted()"
1560-function. If the page is corrupt, it re-reads and retries up to 10 times for each page. It skips this check on the doublewrite buffer.
1561-.SH "AUTHOR"
1562-Percona LLC and/or its affiliates. http://www.percona.com/
1563-.SH "REPORTING BUGS"
1564-Report bugs to https://bugs.launchpad.net/percona-xtrabackup/+filebug
1565-.SH "LICENCE"
1566-GPL version 2
1567-

Subscribers

People subscribed via source and target branches