|
| 1 | +# Backup lifecycle |
| 2 | + |
| 3 | +Quick-scan facts—privileges, phases, defaults, behavior. For a walkthrough see the [tutorial](how-xtrabackup-works-tutorial.md); for procedures see the [how-to](how-xtrabackup-works-how-to.md). |
| 4 | + |
| 5 | + |
| 6 | +## Privileges (summary) |
| 7 | + |
| 8 | +| Privilege | Typical use | |
| 9 | +|-----------|-------------| |
| 10 | +| `BACKUP_ADMIN` | Read `performance_schema.log_status`; use `LOCK INSTANCE FOR BACKUP`, `LOCK TABLES FOR BACKUP`, `LOCK BINLOG FOR BACKUP` when applicable | |
| 11 | +| `RELOAD` | Workflows using `FLUSH TABLES WITH READ LOCK` or similar | |
| 12 | +| `LOCK TABLES` | Workflows that issue table-level locks | |
| 13 | +| `REPLICATION CLIENT` | `--slave-info` and related replication metadata | |
| 14 | + |
| 15 | +[Connection and privileges needed](privileges.md) has the full list. |
| 16 | + |
| 17 | +## Three operator-facing phases |
| 18 | + |
| 19 | +| Step | Phase | What happens | |
| 20 | +|------|-------|----------------| |
| 21 | +| 1 | Backup (hot copy) | Copy data files; stream redo for the whole run | |
| 22 | +| 2 | Prepare | Replay redo; roll back uncommitted work | |
| 23 | +| 3 | Restore | `--copy-back` or `--move-back` into `datadir` | |
| 24 | + |
| 25 | +## Three in-backup sub-phases (locking) |
| 26 | + |
| 27 | +With backup locks, Percona XtraBackup (PXB) typically runs the stages in the table below. Each numbered row is a phase in order: the Locks column is the global lock posture for that phase, and the Work column is what PXB copies or records while those locks apply—InnoDB pages and redo first (often with no global backup lock), then non-InnoDB files under the backup lock (with DDL restricted), then a short `LOCK BINLOG FOR BACKUP` to pin binlog or replica coordinates. Exact steps depend on server version and which storage engines are in use. |
| 28 | + |
| 29 | +| # | Locks | Work | |
| 30 | +|---|--------|------| |
| 31 | +| 1 | None global | Copy InnoDB files and redo while data manipulation language (DML) runs | |
| 32 | +| 2 | Backup lock | Copy non-InnoDB files (e.g. `.frm`, `.MRG`, `.MYD`, `.MYI`, `.CSM`, `.CSV`, `.sdi` (serialized dictionary information), `.par`); data definition language (DDL) restricted, DML usually allowed—details are server-specific | |
| 33 | +| 3 | `LOCK BINLOG FOR BACKUP` (short) | Pin binlog/replica coordinates; read `performance_schema.log_status`; drop locks | |
| 34 | + |
| 35 | +Backup locks vs FTWRL (`FLUSH TABLES WITH READ LOCK`): [Percona Server backup locks](https://docs.percona.com/percona-server/innovation-release/backup-locks.html). |
| 36 | +MySQL {{vers}}: [`LOCK INSTANCE FOR BACKUP`](https://dev.mysql.com/doc/refman/{{vers}}/en/lock-instance-for-backup.html). |
| 37 | + |
| 38 | +## `--lock-ddl` |
| 39 | + |
| 40 | +| Value | When the backup lock is taken (typical) | |
| 41 | +|-------|----------------------------------------| |
| 42 | +| `ON` (default) | Backup start | |
| 43 | +| `REDUCED` | After InnoDB data copy finishes | |
| 44 | + |
| 45 | +`ON` blocks DDL for the whole window from the beginning; `REDUCED` delays that until InnoDB is copied (shorter DDL stall, different overlap with DDL during the InnoDB phase). InnoDB DML usually keeps running through the main copy. |
| 46 | + |
| 47 | +## `--register-redo-log-consumer` |
| 48 | + |
| 49 | +| Field | Detail | |
| 50 | +|-------|--------| |
| 51 | +| Default | Off | |
| 52 | +| Does | Registers PXB as a redo consumer so the server won’t purge a redo file until PXB copies that file | |
| 53 | +| Cost | Redo can pile up (“redo bloat”); disk use may spike | |
| 54 | +| Writes | Server may stall writes briefly while the consumer advances | |
| 55 | + |
| 56 | +## Prepare options (subset) |
| 57 | + |
| 58 | +| Option | Notes | |
| 59 | +|--------|--------| |
| 60 | +| `--use-memory` | Random-access memory (RAM) for prepare only (default 100MB); larger often helps | |
| 61 | +| `--parallel` | 8.4.0-3+: parallel `.delta` apply for incrementals; not the same as parallel full-backup redo replay | |
| 62 | + |
| 63 | +Full flags: [xtrabackup option reference](xtrabackup-option-reference.md). |
| 64 | + |
| 65 | +## Restore (facts) |
| 66 | + |
| 67 | +* Pulls paths from `my.cnf` (e.g. `datadir`, `innodb_data_home_dir`, `innodb_data_file_path`, `innodb_log_group_home_dir`). |
| 68 | + |
| 69 | +* Order: MyISAM-family files first (`.MRG`, `.MYD`, `.MYI`, `.CSM`, `.CSV`, `.sdi`, `.par`), then InnoDB tables/indexes, then logs. |
| 70 | + |
| 71 | +* Keeps file attributes. |
| 72 | + |
| 73 | +* Successful backup prints binlog coordinates to standard error (STDERR)—redirect if you need a file. |
| 74 | + |
| 75 | +## When backup locks are skipped (“lockless”) |
| 76 | + |
| 77 | +Locks stay off only if every table in every schema—including `mysql`—is InnoDB. Commonly `mysql` still holds CSV/MyISAM tables (e.g. `general_log`), so PXB usually takes backup locks anyway. |
| 78 | + |
| 79 | +| Server | Notes | |
| 80 | +|--------|--------| |
| 81 | +| Percona Server for MySQL {{vers}} | `log_status` may carry relay coordinates; `--slave-info` can skip extra locks | |
| 82 | +| Standard MySQL {{vers}} | May still need `FLUSH TABLES WITH READ LOCK` with `--slave-info` when you need relay position | |
| 83 | + |
| 84 | +## Cloud / streaming |
| 85 | + |
| 86 | +Same phases; slow networks stretch Final Sync and can lengthen short locks. [Streaming backup](take-streaming-backup.md), [xbcloud overview](xbcloud-binary-overview.md). |
| 87 | + |
| 88 | +## See also |
| 89 | + |
| 90 | +* [Index of files created by Percona XtraBackup](xtrabackup-files.md) |
| 91 | + |
| 92 | +* [Restore full, incremental, and compressed backups](restore-a-backup.md) |
0 commit comments