Jiri Broulik | 634ea8a | 2017-05-31 17:10:03 +0200 | [diff] [blame] | 1 | |
| 2 | =================== |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 3 | Usage |
Jiri Broulik | 634ea8a | 2017-05-31 17:10:03 +0200 | [diff] [blame] | 4 | =================== |
| 5 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 6 | Xtrabackup allows you to backup and restore databases from full |
| 7 | backups or full backups and its incrementals. |
Jiri Broulik | 634ea8a | 2017-05-31 17:10:03 +0200 | [diff] [blame] | 8 | |
| 9 | Sample pillars |
| 10 | ============== |
| 11 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 12 | Backup client with ssh/rsync remote host: |
Jiri Broulik | 634ea8a | 2017-05-31 17:10:03 +0200 | [diff] [blame] | 13 | |
| 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 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 28 | .. 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 Broulik | 634ea8a | 2017-05-31 17:10:03 +0200 | [diff] [blame] | 31 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 32 | Backup client with local backup only: |
Jiri Broulik | 634ea8a | 2017-05-31 17:10:03 +0200 | [diff] [blame] | 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 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 46 | .. note:: The ``full_backups_to_keep`` parameter states how many backup will |
| 47 | be stored locally on xtrabackup client. |
Jiri Broulik | 634ea8a | 2017-05-31 17:10:03 +0200 | [diff] [blame] | 48 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 49 | Backup client with ssh/rsync to remote host with compression and non-default |
| 50 | backup directory on server: |
Jiri Broulik | 634ea8a | 2017-05-31 17:10:03 +0200 | [diff] [blame] | 51 | |
| 52 | .. code-block:: yaml |
| 53 | |
| 54 | xtrabackup: |
| 55 | client: |
| 56 | enabled: true |
| 57 | full_backups_to_keep: 3 |
| 58 | hours_before_full: 48 |
| 59 | hours_before_incr: 12 |
| 60 | compression: true |
| 61 | compression_threads: 2 |
| 62 | database: |
| 63 | user: username |
| 64 | password: password |
| 65 | target: |
| 66 | host: cfg01 |
Marcin Iwinski | f74b953 | 2017-09-28 16:30:47 +0200 | [diff] [blame] | 67 | server: |
| 68 | enabled: false |
| 69 | backup_dir: /srv/backup |
Jiri Broulik | 634ea8a | 2017-05-31 17:10:03 +0200 | [diff] [blame] | 70 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 71 | .. note:: More options to relocate local backups can be done using |
| 72 | ``salt-formula-backupninja``. |
Jiri Broulik | 634ea8a | 2017-05-31 17:10:03 +0200 | [diff] [blame] | 73 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 74 | .. note:: If the ``server`` section is ommited, backups will be made to |
| 75 | default location, same on both client and server side. |
Marcin Iwinski | f74b953 | 2017-09-28 16:30:47 +0200 | [diff] [blame] | 76 | |
Martin Polreich | f33e186 | 2018-03-02 10:30:35 +0100 | [diff] [blame] | 77 | Backup client at exact times: |
| 78 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 79 | .. code-block:: yaml |
Martin Polreich | f33e186 | 2018-03-02 10:30:35 +0100 | [diff] [blame] | 80 | |
| 81 | xtrabackup: |
| 82 | client: |
| 83 | enabled: true |
| 84 | full_backups_to_keep: 3 |
| 85 | incr_before_full: 3 |
| 86 | backup_dir: /var/backups/mysql/xtrabackup |
| 87 | backup_times: |
Martin Polreich | 3694851 | 2018-04-04 10:07:58 +0200 | [diff] [blame] | 88 | day_of_week: 0 |
Martin Polreich | f33e186 | 2018-03-02 10:30:35 +0100 | [diff] [blame] | 89 | hour: 4 |
| 90 | minute: 52 |
| 91 | compression: true |
| 92 | compression_threads: 2 |
| 93 | database: |
| 94 | user: user |
| 95 | password: password |
| 96 | target: |
| 97 | host: host01 |
| 98 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 99 | .. note:: Parameters in ``backup_times`` section can be used to set up exact |
| 100 | time the cron job should be executed. In this example, the backup job |
| 101 | would be executed every Sunday at 4:52 AM. If any of the individual |
| 102 | ``backup_times`` parameters is not defined, the defalut ``*`` value will |
| 103 | be used. For example, if minute parameter is ``*``, it will run the backup |
| 104 | every minute, which is ususally not desired. |
Martin Polreich | f33e186 | 2018-03-02 10:30:35 +0100 | [diff] [blame] | 105 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 106 | Available parameters include: |
Martin Polreich | f33e186 | 2018-03-02 10:30:35 +0100 | [diff] [blame] | 107 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 108 | * ``day_of_week`` |
| 109 | * ``day_of_month`` |
| 110 | * ``month`` |
| 111 | * ``hour`` |
| 112 | * ``minute``. |
Martin Polreich | f33e186 | 2018-03-02 10:30:35 +0100 | [diff] [blame] | 113 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 114 | See the crontab reference for further info on how to set these |
| 115 | parameters. |
| 116 | |
| 117 | .. note:: Please be aware that only ``backup_times`` section OR |
| 118 | ``hours_before_full(incr)`` can be defined. If both are defined. The |
| 119 | ``backup_times`` section will be peferred. |
| 120 | |
| 121 | .. note:: New parameter ``incr_before_full`` needs to be defined. This |
| 122 | number sets number of incremental backups to be run, before a full backup |
| 123 | is performed. |
Martin Polreich | f33e186 | 2018-03-02 10:30:35 +0100 | [diff] [blame] | 124 | |
Marcin Iwinski | f74b953 | 2017-09-28 16:30:47 +0200 | [diff] [blame] | 125 | Backup server rsync and non-default backup directory: |
Jiri Broulik | 634ea8a | 2017-05-31 17:10:03 +0200 | [diff] [blame] | 126 | |
| 127 | .. code-block:: yaml |
| 128 | |
| 129 | xtrabackup: |
| 130 | server: |
| 131 | enabled: true |
| 132 | hours_before_full: 48 |
| 133 | full_backups_to_keep: 5 |
| 134 | key: |
| 135 | xtrabackup_pub_key: |
| 136 | enabled: true |
| 137 | key: key |
Marcin Iwinski | f74b953 | 2017-09-28 16:30:47 +0200 | [diff] [blame] | 138 | backup_dir: /srv/backup |
Jiri Broulik | 634ea8a | 2017-05-31 17:10:03 +0200 | [diff] [blame] | 139 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 140 | .. note:: The ``hours_before_full`` parameter should have the same value as |
| 141 | is stated on xtrabackup client |
Jiri Broulik | 634ea8a | 2017-05-31 17:10:03 +0200 | [diff] [blame] | 142 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 143 | .. note:: If the ``backup_dir`` argument is ommited backups will be made to |
| 144 | default location, same on both client and server side. |
Jiri Broulik | 634ea8a | 2017-05-31 17:10:03 +0200 | [diff] [blame] | 145 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 146 | Backup server without strict client restriction: |
Jiri Broulik | e662620 | 2018-02-28 16:22:20 +0100 | [diff] [blame] | 147 | |
| 148 | .. code-block:: yaml |
| 149 | |
| 150 | xtrabackup: |
| 151 | server: |
| 152 | restrict_clients: false |
| 153 | |
Martin Polreich | f33e186 | 2018-03-02 10:30:35 +0100 | [diff] [blame] | 154 | Backup server at exact times: |
| 155 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 156 | .. code-block:: yaml |
Martin Polreich | f33e186 | 2018-03-02 10:30:35 +0100 | [diff] [blame] | 157 | |
| 158 | xtrabackup: |
| 159 | server: |
| 160 | enabled: true |
| 161 | full_backups_to_keep: 3 |
| 162 | incr_before_full: 3 |
| 163 | backup_dir: /srv/backup |
| 164 | backup_times: |
Martin Polreich | 3694851 | 2018-04-04 10:07:58 +0200 | [diff] [blame] | 165 | day_of_week: 0 |
Martin Polreich | f33e186 | 2018-03-02 10:30:35 +0100 | [diff] [blame] | 166 | hour: 4 |
| 167 | minute: 52 |
| 168 | key: |
| 169 | xtrabackup_pub_key: |
| 170 | enabled: true |
| 171 | key: key |
| 172 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 173 | .. note:: Parameters in ``backup_times`` section can be used to set up exact |
| 174 | time the cron job should be executed. In this example, the backup job |
| 175 | would be executed every Sunday at 4:52 AM. If any of the individual |
| 176 | ``backup_times`` parameters is not defined, the defalut ``*`` value will |
| 177 | be used. For example, if minute parameter is ``*``, it will run the backup |
| 178 | every minute, which is ususally not desired. |
Martin Polreich | f33e186 | 2018-03-02 10:30:35 +0100 | [diff] [blame] | 179 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 180 | See the crontab reference for further info on how to set these parameters. |
Martin Polreich | f33e186 | 2018-03-02 10:30:35 +0100 | [diff] [blame] | 181 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 182 | .. note:: Please be aware that only ``backup_times`` section OR |
| 183 | ``hours_before_full(incr)`` can be defined. If both are defined. The |
| 184 | ``backup_times`` section will be peferred. |
| 185 | |
| 186 | .. note:: New parameter ``incr_before_full`` needs to be defined. This |
| 187 | number sets number of incremental backups to be run, before a full backup |
| 188 | is performed. |
Martin Polreich | f33e186 | 2018-03-02 10:30:35 +0100 | [diff] [blame] | 189 | |
Jiri Broulik | e662620 | 2018-02-28 16:22:20 +0100 | [diff] [blame] | 190 | Client restore from local backups: |
Jiri Broulik | 634ea8a | 2017-05-31 17:10:03 +0200 | [diff] [blame] | 191 | |
| 192 | .. code-block:: yaml |
| 193 | |
| 194 | xtrabackup: |
| 195 | client: |
| 196 | enabled: true |
| 197 | full_backups_to_keep: 5 |
| 198 | hours_before_full: 48 |
| 199 | hours_before_incr: 12 |
| 200 | restore_full_latest: 1 |
| 201 | restore_from: local |
| 202 | compression: true |
| 203 | compressThreads: 2 |
| 204 | database: |
| 205 | user: username |
| 206 | password: password |
| 207 | target: |
| 208 | host: cfg01 |
| 209 | qpress: |
| 210 | source: tar |
| 211 | name: url |
| 212 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 213 | .. note:: restore_full_latest param with a value of 1 means to restore |
| 214 | db from the last full backup and its increments. 2 would mean to |
| 215 | restore second latest full backup and its increments |
Jiri Broulik | 634ea8a | 2017-05-31 17:10:03 +0200 | [diff] [blame] | 216 | |
azvyagintsev | 83c4c64 | 2018-08-20 16:47:51 +0300 | [diff] [blame] | 217 | Client restore from remote backups: |
Jiri Broulik | 634ea8a | 2017-05-31 17:10:03 +0200 | [diff] [blame] | 218 | |
| 219 | .. code-block:: yaml |
| 220 | |
| 221 | xtrabackup: |
| 222 | client: |
| 223 | enabled: true |
| 224 | full_backups_to_keep: 5 |
| 225 | hours_before_full: 48 |
| 226 | hours_before_incr: 12 |
| 227 | restore_full_latest: 1 |
| 228 | restore_from: remote |
| 229 | compression: true |
| 230 | compressThreads: 2 |
| 231 | database: |
| 232 | user: username |
| 233 | password: password |
| 234 | target: |
| 235 | host: cfg01 |
| 236 | qpress: |
| 237 | source: tar |
| 238 | name: url |
| 239 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 240 | .. note:: The ``restore_full_latest`` parameter with a value of 1 |
| 241 | means to restore db from the last full backup and its increments. |
| 242 | 2 would mean to restore second latest full backup and its increments |
Jiri Broulik | 634ea8a | 2017-05-31 17:10:03 +0200 | [diff] [blame] | 243 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 244 | Read more |
| 245 | ========= |
Jiri Broulik | 634ea8a | 2017-05-31 17:10:03 +0200 | [diff] [blame] | 246 | |
| 247 | * https://labs.riseup.net/code/projects/xtrabackup/wiki/Configuration |
| 248 | * http://www.debian-administration.org/articles/351 |
| 249 | * http://duncanlock.net/blog/2013/08/27/comprehensive-linux-backups-with-etckeeper-xtrabackup/ |
| 250 | * https://github.com/riseuplabs/puppet-xtrabackup |
| 251 | * http://www.ushills.co.uk/2008/02/backup-with-xtrabackup.html |
| 252 | |
Jiri Broulik | 634ea8a | 2017-05-31 17:10:03 +0200 | [diff] [blame] | 253 | Documentation and Bugs |
| 254 | ====================== |
| 255 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 256 | * http://salt-formulas.readthedocs.io/ |
| 257 | Learn how to install and update salt-formulas |
Jiri Broulik | 634ea8a | 2017-05-31 17:10:03 +0200 | [diff] [blame] | 258 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 259 | * https://github.com/salt-formulas/salt-formula-xtrabackup/issues |
| 260 | In the unfortunate event that bugs are discovered, report the issue to the |
| 261 | appropriate issue tracker. Use the Github issue tracker for a specific salt |
| 262 | formula |
Jiri Broulik | 634ea8a | 2017-05-31 17:10:03 +0200 | [diff] [blame] | 263 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 264 | * https://launchpad.net/salt-formulas |
| 265 | For feature requests, bug reports, or blueprints affecting the entire |
| 266 | ecosystem, use the Launchpad salt-formulas project |
Jiri Broulik | 634ea8a | 2017-05-31 17:10:03 +0200 | [diff] [blame] | 267 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 268 | * https://launchpad.net/~salt-formulas-users |
| 269 | Join the salt-formulas-users team and subscribe to mailing list if required |
Jiri Broulik | 634ea8a | 2017-05-31 17:10:03 +0200 | [diff] [blame] | 270 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 271 | * https://github.com/salt-formulas/salt-formula-xtrabackup |
| 272 | Develop the salt-formulas projects in the master branch and then submit pull |
| 273 | requests against a specific formula |
Jiri Broulik | 634ea8a | 2017-05-31 17:10:03 +0200 | [diff] [blame] | 274 | |
OlgaGusarenko | a8a80d3 | 2018-07-31 01:31:34 +0300 | [diff] [blame] | 275 | * #salt-formulas @ irc.freenode.net |
| 276 | Use this IRC channel in case of any questions or feedback which is always |
| 277 | welcome |
Jiri Broulik | 634ea8a | 2017-05-31 17:10:03 +0200 | [diff] [blame] | 278 | |