blob: 101134e62ea9b1dc68fa54c597f37e7ed6b015b3 [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
82 compression_threads: 2
Adam Tengler5b9dd512018-09-10 15:06:20 +000083 throttle: 20
Jiri Broulik634ea8a2017-05-31 17:10:03 +020084 database:
85 user: username
86 password: password
87 target:
88 host: cfg01
Marcin Iwinskif74b9532017-09-28 16:30:47 +020089 server:
90 enabled: false
91 backup_dir: /srv/backup
Jiri Broulik634ea8a2017-05-31 17:10:03 +020092
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +030093.. note:: More options to relocate local backups can be done using
94 ``salt-formula-backupninja``.
Jiri Broulik634ea8a2017-05-31 17:10:03 +020095
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +030096.. note:: If the ``server`` section is ommited, backups will be made to
97 default location, same on both client and server side.
Marcin Iwinskif74b9532017-09-28 16:30:47 +020098
Martin Polreichf33e1862018-03-02 10:30:35 +010099Backup client at exact times:
100
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300101.. code-block:: yaml
Martin Polreichf33e1862018-03-02 10:30:35 +0100102
103 xtrabackup:
104 client:
105 enabled: true
106 full_backups_to_keep: 3
107 incr_before_full: 3
108 backup_dir: /var/backups/mysql/xtrabackup
109 backup_times:
Martin Polreich36948512018-04-04 10:07:58 +0200110 day_of_week: 0
Martin Polreichf33e1862018-03-02 10:30:35 +0100111 hour: 4
112 minute: 52
113 compression: true
114 compression_threads: 2
115 database:
116 user: user
117 password: password
118 target:
119 host: host01
120
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300121.. note:: Parameters in ``backup_times`` section can be used to set up exact
122 time the cron job should be executed. In this example, the backup job
123 would be executed every Sunday at 4:52 AM. If any of the individual
124 ``backup_times`` parameters is not defined, the defalut ``*`` value will
125 be used. For example, if minute parameter is ``*``, it will run the backup
126 every minute, which is ususally not desired.
Martin Polreichf33e1862018-03-02 10:30:35 +0100127
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300128 Available parameters include:
Martin Polreichf33e1862018-03-02 10:30:35 +0100129
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300130 * ``day_of_week``
131 * ``day_of_month``
132 * ``month``
133 * ``hour``
134 * ``minute``.
Martin Polreichf33e1862018-03-02 10:30:35 +0100135
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300136 See the crontab reference for further info on how to set these
137 parameters.
138
139.. note:: Please be aware that only ``backup_times`` section OR
140 ``hours_before_full(incr)`` can be defined. If both are defined. The
141 ``backup_times`` section will be peferred.
142
143.. note:: New parameter ``incr_before_full`` needs to be defined. This
144 number sets number of incremental backups to be run, before a full backup
145 is performed.
Martin Polreichf33e1862018-03-02 10:30:35 +0100146
Marcin Iwinskif74b9532017-09-28 16:30:47 +0200147Backup server rsync and non-default backup directory:
Jiri Broulik634ea8a2017-05-31 17:10:03 +0200148
149.. code-block:: yaml
150
151 xtrabackup:
152 server:
153 enabled: true
154 hours_before_full: 48
155 full_backups_to_keep: 5
156 key:
157 xtrabackup_pub_key:
158 enabled: true
159 key: key
Marcin Iwinskif74b9532017-09-28 16:30:47 +0200160 backup_dir: /srv/backup
Jiri Broulik634ea8a2017-05-31 17:10:03 +0200161
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300162.. note:: The ``hours_before_full`` parameter should have the same value as
163 is stated on xtrabackup client
Jiri Broulik634ea8a2017-05-31 17:10:03 +0200164
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300165.. note:: If the ``backup_dir`` argument is ommited backups will be made to
166 default location, same on both client and server side.
Jiri Broulik634ea8a2017-05-31 17:10:03 +0200167
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300168Backup server without strict client restriction:
Jiri Broulike6626202018-02-28 16:22:20 +0100169
170.. code-block:: yaml
171
172 xtrabackup:
173 server:
174 restrict_clients: false
175
Martin Polreichf33e1862018-03-02 10:30:35 +0100176Backup server at exact times:
177
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300178.. code-block:: yaml
Martin Polreichf33e1862018-03-02 10:30:35 +0100179
180 xtrabackup:
181 server:
182 enabled: true
183 full_backups_to_keep: 3
184 incr_before_full: 3
185 backup_dir: /srv/backup
186 backup_times:
Martin Polreich36948512018-04-04 10:07:58 +0200187 day_of_week: 0
Martin Polreichf33e1862018-03-02 10:30:35 +0100188 hour: 4
189 minute: 52
190 key:
191 xtrabackup_pub_key:
192 enabled: true
193 key: key
194
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300195.. note:: Parameters in ``backup_times`` section can be used to set up exact
196 time the cron job should be executed. In this example, the backup job
197 would be executed every Sunday at 4:52 AM. If any of the individual
198 ``backup_times`` parameters is not defined, the defalut ``*`` value will
199 be used. For example, if minute parameter is ``*``, it will run the backup
200 every minute, which is ususally not desired.
Martin Polreichf33e1862018-03-02 10:30:35 +0100201
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300202 See the crontab reference for further info on how to set these parameters.
Martin Polreichf33e1862018-03-02 10:30:35 +0100203
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300204.. note:: Please be aware that only ``backup_times`` section OR
205 ``hours_before_full(incr)`` can be defined. If both are defined. The
206 ``backup_times`` section will be peferred.
207
208.. note:: New parameter ``incr_before_full`` needs to be defined. This
209 number sets number of incremental backups to be run, before a full backup
210 is performed.
Martin Polreichf33e1862018-03-02 10:30:35 +0100211
Jiri Broulike6626202018-02-28 16:22:20 +0100212Client restore from local backups:
Jiri Broulik634ea8a2017-05-31 17:10:03 +0200213
214.. code-block:: yaml
215
216 xtrabackup:
217 client:
218 enabled: true
219 full_backups_to_keep: 5
220 hours_before_full: 48
221 hours_before_incr: 12
222 restore_full_latest: 1
223 restore_from: local
224 compression: true
225 compressThreads: 2
226 database:
227 user: username
228 password: password
229 target:
230 host: cfg01
231 qpress:
232 source: tar
233 name: url
234
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300235.. note:: restore_full_latest param with a value of 1 means to restore
236 db from the last full backup and its increments. 2 would mean to
237 restore second latest full backup and its increments
Jiri Broulik634ea8a2017-05-31 17:10:03 +0200238
azvyagintsev83c4c642018-08-20 16:47:51 +0300239Client restore from remote backups:
Jiri Broulik634ea8a2017-05-31 17:10:03 +0200240
241.. code-block:: yaml
242
243 xtrabackup:
244 client:
245 enabled: true
246 full_backups_to_keep: 5
247 hours_before_full: 48
248 hours_before_incr: 12
249 restore_full_latest: 1
250 restore_from: remote
251 compression: true
252 compressThreads: 2
253 database:
254 user: username
255 password: password
256 target:
257 host: cfg01
258 qpress:
259 source: tar
260 name: url
261
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300262.. note:: The ``restore_full_latest`` parameter with a value of 1
263 means to restore db from the last full backup and its increments.
264 2 would mean to restore second latest full backup and its increments
Jiri Broulik634ea8a2017-05-31 17:10:03 +0200265
OlgaGusarenkoa8a80d32018-07-31 01:31:34 +0300266Read more
267=========
Jiri Broulik634ea8a2017-05-31 17:10:03 +0200268
269* https://labs.riseup.net/code/projects/xtrabackup/wiki/Configuration
270* http://www.debian-administration.org/articles/351
271* http://duncanlock.net/blog/2013/08/27/comprehensive-linux-backups-with-etckeeper-xtrabackup/
272* https://github.com/riseuplabs/puppet-xtrabackup
273* http://www.ushills.co.uk/2008/02/backup-with-xtrabackup.html