blob: 6b04064acb44a5b2a905f44627d1b93cc53ec0d1 [file] [log] [blame]
Jiri Broulik634ea8a2017-05-31 17:10:03 +02001
2===================
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +03003Usage
Jiri Broulik634ea8a2017-05-31 17:10:03 +02004===================
5
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +03006Xtrabackup allows you to backup and restore databases from full
7backups or full backups and its incrementals.
Jiri Broulik634ea8a2017-05-31 17:10:03 +02008
9Sample pillars
10==============
11
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +030012Backup client with ssh/rsync remote host:
Jiri Broulik634ea8a2017-05-31 17:10:03 +020013
14.. code-block:: yaml
15
16 xtrabackup:
17 client:
18 enabled: true
19 full_backups_to_keep: 3
20 hours_before_full: 48
21 hours_before_incr: 12
22 database:
23 user: username
24 password: password
25 target:
26 host: cfg01
27
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +030028.. note:: The ``full_backups_to_keep`` parameter states how many backup will
29 be stored locally on xtrabackup client. More options to relocate local
30 backups can be done using ``salt-formula-backupninja``.
Jiri Broulik634ea8a2017-05-31 17:10:03 +020031
Adam Tengler5b9dd512018-09-10 15:06:20 +000032Backup client using DB API instead of socket (still needs to be run on the same server as DB):
33
34.. code-block:: yaml
35
36 xtrabackup:
37 client:
38 enabled: true
39 full_backups_to_keep: 3
40 hours_before_full: 48
41 hours_before_incr: 12
42 database:
43 user: username
44 password: password
45 host: localhost
46 port: 3306
47 target:
48 host: cfg01
49
50.. note:: DB user ``username`` must have "RELOAD" and "REPLICATION CLIENT"
51 privileges on all databases.
52
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +030053Backup client with local backup only:
Jiri Broulik634ea8a2017-05-31 17:10:03 +020054
55.. code-block:: yaml
56
57 xtrabackup:
58 client:
59 enabled: true
60 full_backups_to_keep: 3
61 hours_before_full: 48
62 hours_before_incr: 12
63 database:
64 user: username
65 password: password
66
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +030067.. note:: The ``full_backups_to_keep`` parameter states how many backup will
68 be stored locally on xtrabackup client.
Jiri Broulik634ea8a2017-05-31 17:10:03 +020069
Adam Tengler5b9dd512018-09-10 15:06:20 +000070Backup client with ssh/rsync to remote host with compression, IO throttling and non-default
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +030071backup directory on server:
Jiri Broulik634ea8a2017-05-31 17:10:03 +020072
73.. code-block:: yaml
74
75 xtrabackup:
76 client:
77 enabled: true
78 full_backups_to_keep: 3
79 hours_before_full: 48
80 hours_before_incr: 12
81 compression: true
Ivan Berezovskiyf94c1c32019-07-25 15:53:40 +040082 rsync_tables: true
Jiri Broulik634ea8a2017-05-31 17:10:03 +020083 compression_threads: 2
Adam Tengler5b9dd512018-09-10 15:06:20 +000084 throttle: 20
Jiri Broulik634ea8a2017-05-31 17:10:03 +020085 database:
86 user: username
87 password: password
88 target:
89 host: cfg01
Marcin Iwinskif74b9532017-09-28 16:30:47 +020090 server:
91 enabled: false
92 backup_dir: /srv/backup
Jiri Broulik634ea8a2017-05-31 17:10:03 +020093
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +030094.. note:: More options to relocate local backups can be done using
95 ``salt-formula-backupninja``.
Jiri Broulik634ea8a2017-05-31 17:10:03 +020096
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +030097.. note:: If the ``server`` section is ommited, backups will be made to
98 default location, same on both client and server side.
Marcin Iwinskif74b9532017-09-28 16:30:47 +020099
Martin Polreichf33e1862018-03-02 10:30:35 +0100100Backup client at exact times:
101
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300102.. code-block:: yaml
Martin Polreichf33e1862018-03-02 10:30:35 +0100103
104 xtrabackup:
105 client:
106 enabled: true
107 full_backups_to_keep: 3
108 incr_before_full: 3
109 backup_dir: /var/backups/mysql/xtrabackup
110 backup_times:
Martin Polreich36948512018-04-04 10:07:58 +0200111 day_of_week: 0
Martin Polreichf33e1862018-03-02 10:30:35 +0100112 hour: 4
113 minute: 52
114 compression: true
Ivan Berezovskiyf94c1c32019-07-25 15:53:40 +0400115 rsync_tables: true
Martin Polreichf33e1862018-03-02 10:30:35 +0100116 compression_threads: 2
117 database:
118 user: user
119 password: password
120 target:
121 host: host01
122
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300123.. note:: Parameters in ``backup_times`` section can be used to set up exact
124 time the cron job should be executed. In this example, the backup job
125 would be executed every Sunday at 4:52 AM. If any of the individual
126 ``backup_times`` parameters is not defined, the defalut ``*`` value will
127 be used. For example, if minute parameter is ``*``, it will run the backup
128 every minute, which is ususally not desired.
Martin Polreichf33e1862018-03-02 10:30:35 +0100129
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300130 Available parameters include:
Martin Polreichf33e1862018-03-02 10:30:35 +0100131
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300132 * ``day_of_week``
133 * ``day_of_month``
134 * ``month``
135 * ``hour``
136 * ``minute``.
Martin Polreichf33e1862018-03-02 10:30:35 +0100137
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300138 See the crontab reference for further info on how to set these
139 parameters.
140
141.. note:: Please be aware that only ``backup_times`` section OR
142 ``hours_before_full(incr)`` can be defined. If both are defined. The
143 ``backup_times`` section will be peferred.
144
145.. note:: New parameter ``incr_before_full`` needs to be defined. This
146 number sets number of incremental backups to be run, before a full backup
147 is performed.
Martin Polreichf33e1862018-03-02 10:30:35 +0100148
Marcin Iwinskif74b9532017-09-28 16:30:47 +0200149Backup server rsync and non-default backup directory:
Jiri Broulik634ea8a2017-05-31 17:10:03 +0200150
151.. code-block:: yaml
152
153 xtrabackup:
154 server:
155 enabled: true
156 hours_before_full: 48
157 full_backups_to_keep: 5
158 key:
159 xtrabackup_pub_key:
160 enabled: true
161 key: key
Marcin Iwinskif74b9532017-09-28 16:30:47 +0200162 backup_dir: /srv/backup
Jiri Broulik634ea8a2017-05-31 17:10:03 +0200163
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300164.. note:: The ``hours_before_full`` parameter should have the same value as
165 is stated on xtrabackup client
Jiri Broulik634ea8a2017-05-31 17:10:03 +0200166
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300167.. note:: If the ``backup_dir`` argument is ommited backups will be made to
168 default location, same on both client and server side.
Jiri Broulik634ea8a2017-05-31 17:10:03 +0200169
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300170Backup server without strict client restriction:
Jiri Broulike6626202018-02-28 16:22:20 +0100171
172.. code-block:: yaml
173
174 xtrabackup:
175 server:
176 restrict_clients: false
177
Martin Polreichf33e1862018-03-02 10:30:35 +0100178Backup server at exact times:
179
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300180.. code-block:: yaml
Martin Polreichf33e1862018-03-02 10:30:35 +0100181
182 xtrabackup:
183 server:
184 enabled: true
185 full_backups_to_keep: 3
186 incr_before_full: 3
187 backup_dir: /srv/backup
188 backup_times:
Martin Polreich36948512018-04-04 10:07:58 +0200189 day_of_week: 0
Martin Polreichf33e1862018-03-02 10:30:35 +0100190 hour: 4
191 minute: 52
192 key:
193 xtrabackup_pub_key:
194 enabled: true
195 key: key
196
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300197.. note:: Parameters in ``backup_times`` section can be used to set up exact
198 time the cron job should be executed. In this example, the backup job
199 would be executed every Sunday at 4:52 AM. If any of the individual
200 ``backup_times`` parameters is not defined, the defalut ``*`` value will
201 be used. For example, if minute parameter is ``*``, it will run the backup
202 every minute, which is ususally not desired.
Martin Polreichf33e1862018-03-02 10:30:35 +0100203
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300204 See the crontab reference for further info on how to set these parameters.
Martin Polreichf33e1862018-03-02 10:30:35 +0100205
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300206.. note:: Please be aware that only ``backup_times`` section OR
207 ``hours_before_full(incr)`` can be defined. If both are defined. The
208 ``backup_times`` section will be peferred.
209
210.. note:: New parameter ``incr_before_full`` needs to be defined. This
211 number sets number of incremental backups to be run, before a full backup
212 is performed.
Martin Polreichf33e1862018-03-02 10:30:35 +0100213
Jiri Broulike6626202018-02-28 16:22:20 +0100214Client restore from local backups:
Jiri Broulik634ea8a2017-05-31 17:10:03 +0200215
216.. code-block:: yaml
217
218 xtrabackup:
219 client:
220 enabled: true
221 full_backups_to_keep: 5
222 hours_before_full: 48
223 hours_before_incr: 12
224 restore_full_latest: 1
225 restore_from: local
226 compression: true
Ivan Berezovskiyf94c1c32019-07-25 15:53:40 +0400227 rsync_tables: true
Jiri Broulik634ea8a2017-05-31 17:10:03 +0200228 compressThreads: 2
229 database:
230 user: username
231 password: password
232 target:
233 host: cfg01
234 qpress:
235 source: tar
236 name: url
237
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300238.. note:: restore_full_latest param with a value of 1 means to restore
239 db from the last full backup and its increments. 2 would mean to
240 restore second latest full backup and its increments
Jiri Broulik634ea8a2017-05-31 17:10:03 +0200241
azvyagintsev83c4c642018-08-20 16:47:51 +0300242Client restore from remote backups:
Jiri Broulik634ea8a2017-05-31 17:10:03 +0200243
244.. code-block:: yaml
245
246 xtrabackup:
247 client:
248 enabled: true
249 full_backups_to_keep: 5
250 hours_before_full: 48
251 hours_before_incr: 12
252 restore_full_latest: 1
253 restore_from: remote
254 compression: true
Ivan Berezovskiyf94c1c32019-07-25 15:53:40 +0400255 rsync_tables: true
Jiri Broulik634ea8a2017-05-31 17:10:03 +0200256 compressThreads: 2
Oleksii Molchanovc8b64972021-04-21 13:24:00 +0300257 force_non_empty_directories: true
Jiri Broulik634ea8a2017-05-31 17:10:03 +0200258 database:
259 user: username
260 password: password
261 target:
262 host: cfg01
263 qpress:
264 source: tar
265 name: url
266
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300267.. note:: The ``restore_full_latest`` parameter with a value of 1
268 means to restore db from the last full backup and its increments.
269 2 would mean to restore second latest full backup and its increments
Jiri Broulik634ea8a2017-05-31 17:10:03 +0200270
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300271Read more
272=========
Jiri Broulik634ea8a2017-05-31 17:10:03 +0200273
274* https://labs.riseup.net/code/projects/xtrabackup/wiki/Configuration
275* http://www.debian-administration.org/articles/351
276* http://duncanlock.net/blog/2013/08/27/comprehensive-linux-backups-with-etckeeper-xtrabackup/
277* https://github.com/riseuplabs/puppet-xtrabackup
278* http://www.ushills.co.uk/2008/02/backup-with-xtrabackup.html