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

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

Subscribers

People subscribed via source and target branches