You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| where to put the dump file; see [backup](./backup.md) | B | `dump --target` | `DB_DUMP_TARGET` | `dump.targets` | |
73
+
| how often to do a dump or prune, in minutes | BP | `dump --frequency` | `DB_DUMP_FREQ` | `dump.schedule.frequency` | `1440` (in minutes), i.e. once per day |
74
+
| what time to do the first dump or prune | BP | `dump --begin` | `DB_DUMP_BEGIN` | `dump.schedule.begin` | `0`, i.e. immediately |
75
+
| cron schedule for dumps or prunes | BP | `dump --cron` | `DB_DUMP_CRON` | `dump.schedule.cron` | |
76
+
| run the backup or prune a single time and exit | BP | `dump --once` | `RUN_ONCE` | `dump.schedule.once` | `false` |
| where to put the dump file; see [backup](./backup.md) | BP | `dump --target` | `DB_DUMP_TARGET` | `dump.targets` | |
79
79
| where the restore file exists; see [restore](./restore.md) | R | `restore --target` | `DB_RESTORE_TARGET` | `restore.target` | |
80
-
| replace any `:` in the dump filename with `-` | B | `dump --safechars` | `DB_DUMP_SAFECHARS` | `database.safechars` | `false` |
81
-
| AWS access key ID, used only if a target does not have one | BR | `aws-access-key-id` | `AWS_ACCESS_KEY_ID` | `dump.targets[s3-target].credentials.access-key-id` | |
82
-
| AWS secret access key, used only if a target does not have one | BR | `aws-secret-access-key` | `AWS_SECRET_ACCESS_KEY` | `dump.targets[s3-target].credentials.secret-access-key` | |
83
-
| AWS default region, used only if a target does not have one | BR | `aws-region` | `AWS_REGION` | `dump.targets[s3-target].region` | |
80
+
| replace any `:` in the dump filename with `-` | BP | `dump --safechars` | `DB_DUMP_SAFECHARS` | `database.safechars` | `false` |
81
+
| AWS access key ID, used only if a target does not have one | BRP | `aws-access-key-id` | `AWS_ACCESS_KEY_ID` | `dump.targets[s3-target].credentials.access-key-id` | |
82
+
| AWS secret access key, used only if a target does not have one | BRP | `aws-secret-access-key` | `AWS_SECRET_ACCESS_KEY` | `dump.targets[s3-target].credentials.secret-access-key` | |
83
+
| AWS default region, used only if a target does not have one | BRP | `aws-region` | `AWS_REGION` | `dump.targets[s3-target].region` | |
84
84
| alternative endpoint URL for S3-interoperable systems, used only if a target does not have one | BR | `aws-endpoint-url` | `AWS_ENDPOINT_URL` | `dump.targets[s3-target].endpoint` | |
85
-
| SMB username, used only if a target does not have one | BR | `smb-user` | `SMB_USER` | `dump.targets[smb-target].credentials.username` | |
86
-
| SMB password, used only if a target does not have one | BR | `smb-pass` | `SMB_PASS` | `dump.targets[smb-target].credentials.password` | |
87
-
| compression to use, one of: `bzip2`, `gzip` | B | `compression` | `COMPRESSION` | `dump.compression` | `gzip` |
85
+
| SMB username, used only if a target does not have one | BRP | `smb-user` | `SMB_USER` | `dump.targets[smb-target].credentials.username` | |
86
+
| SMB password, used only if a target does not have one | BRP | `smb-pass` | `SMB_PASS` | `dump.targets[smb-target].credentials.password` | |
87
+
| compression to use, one of: `bzip2`, `gzip` | BP | `compression` | `COMPRESSION` | `dump.compression` | `gzip` |
88
88
| when in container, run the dump or restore with `nice`/`ionice` | BR | `` | `NICE` | `` | `false` |
89
89
| tmp directory to be used during backup creation and other operations | BR | `tmp` | `TMP_PATH` | `tmp` | system-defined |
90
90
| filename to save the target backup file | B | `dump --filename-pattern` | `DB_DUMP_FILENAME_PATTERN` | `dump.filename-pattern` | |
91
91
| directory with scripts to execute before backup | B | `dump --pre-backup-scripts` | `DB_DUMP_PRE_BACKUP_SCRIPTS` | `dump.scripts.pre-backup` | in container, `/scripts.d/pre-backup/` |
92
92
| directory with scripts to execute after backup | B | `dump --post-backup-scripts` | `DB_DUMP_POST_BACKUP_SCRIPTS` | `dump.scripts.post-backup` | in container, `/scripts.d/post-backup/` |
93
93
| directory with scripts to execute before restore | R | `restore --pre-restore-scripts` | `DB_DUMP_PRE_RESTORE_SCRIPTS` | `dump.pre-restore-scripts` | in container, `/scripts.d/pre-restore/` |
94
94
| directory with scripts to execute after restore | R | `restore --post-restore-scripts` | `DB_DUMP_POST_RESTORE_SCRIPTS` | `dump.post-restore-scripts` | in container, `/scripts.d/post-restore/` |
95
-
96
-
97
-
## Unsupported Options
98
-
99
-
Unsupported options from the old version of `mysql-backup`:
100
-
101
-
* `MYSQLDUMP_OPTS`: A string of options to pass to `mysqldump`, e.g. `MYSQLDUMP_OPTS="--opt abc --param def --max_allowed_packet=123455678"` will run `mysqldump --opt abc --param def --max_allowed_packet=123455678`. These are replaced by individual options.
102
-
* `AWS_CLI_OPTS`: Additional arguments to be passed to the `aws` part of the `aws s3 cp` command, click [here](https://docs.aws.amazon.com/cli/latest/reference/#options) for a list. These are replaced by target-specific options.
103
-
* `AWS_CLI_S3_CP_OPTS`: Additional arguments to be passed to the `s3 cp` part of the `aws s3 cp` command, click [here](https://docs.aws.amazon.com/cli/latest/reference/s3/cp.html#options) for a list. If you are using AWS KMS, `sse`, `sse-kms-key-id`, etc., may be of interest. These are replaced by target-specific options
95
+
| retention policy for backups | BP | `dump --retention` | `RETENTION` | `prune.retention` | Infinite |
Pruning is the process of removing backups that no longer are needed.
4
+
5
+
mysql-backup does **not** do this by default; it is up to you to enable this feature, if you want it.
6
+
7
+
## Launching Pruning
8
+
9
+
Pruning happens only in the following scenarios:
10
+
11
+
* During pruning runs
12
+
* During backup runs
13
+
14
+
It does not occur during restore runs.
15
+
16
+
### Pruning Runs
17
+
18
+
You can start `mysql-backup` with the command `prune` to run a pruning operation. It will prune any backups that are no longer needed.
19
+
20
+
Like backups, it can run once and then exit, or it can run on a schedule.
21
+
22
+
It uses the same configuration options for scheduling as backups, see the [scheduling](./scheduling.md) documentation for more information,
23
+
specifically the section about [Scheduling Options](./scheduling.md#scheduling-options).
24
+
25
+
### Backup Runs
26
+
27
+
When running `mysql-backup` in backup mode, it _optionally_ can also prune older backups before each backup run.
28
+
When enabled, it will prune any backups that fit the pruning criteria.
29
+
30
+
## Pruning Criteria
31
+
32
+
Pruning can be on the basis of the _age_ of a specific backup, or the _number_ of backups. Both are set by the configuration setting:
33
+
34
+
* Environment variable: `RETENTION=<value>`
35
+
* CLI flag: `dump --retention=<value>` or `prune --retention=<value>`
36
+
* Config file:
37
+
```yaml
38
+
prune:
39
+
retention: <value>
40
+
```
41
+
42
+
The value of retention always is an integer followed by a letter. The letter can one of:
43
+
44
+
* `h` - hours, e.g. `2h`
45
+
* `d` - days, e.g. `3d`
46
+
* `w` - weeks, e.g. `4w`
47
+
* `m` - months, e.g. `3m`
48
+
* `y` - years, e.g. `5y`
49
+
* `c` - count, how many backup to keep, e.g. `10c`; this could have been simply `10`, but was kept as `c` to avoid accidental confusion with the other options.
50
+
51
+
Most of these are interchangeable, e.g. `3d` is the same as `72h`, and `4w` is the same as `28d` is the same as `672h`.
52
+
53
+
When calculating whether or not to prune, `mysql-backup` __always__ converts the amount to hours, and then errs on the side of caution.
54
+
For example, if provided `7d`, it will convert that to `168h`, and then prune any backups older than 168 full hours. If it is 167 hours and 59 minutes old, it
55
+
will not be pruned.
56
+
57
+
## Determining backup age
58
+
59
+
Pruning depends on the name of the backup file, rather than the timestamp on the target filesystem, as the latter can be unreliable.
60
+
This means that the filename must be of a known pattern.
61
+
62
+
As of this writing, pruning only work for backup files whose filename uses the default naming scheme, as described in
63
+
["Dump File" in backup documentation](./backup.md#dump-file). We hope to support custom filenames in the future.
0 commit comments