Very simple (heading a bit around)
As with normal backups, it is only within the Docker container that the failure sends mail to the mailbox and deletes data for more than 7 days
Basic Command Description:
Docker exec executes commands in a running container
Parameters:
-D: Detach mode: Run in background
-I: Keep stdin open even without attaching
-T: Assigning a pseudo terminal
Script:
#!/bin/bash
Docker exec-i docker_mysql mysqldump-uroot-pffsdf epel >/backup/$ (date +%f). sql
If [$?-ne 0];then
find/backup/-type f-mtime +7|xargs rm-f
Else
echo "Please log in to host" 127.0.0.1 "check if MySQL backup is normal, backup directory/backup/. " | Mail-s "Backup Failed" [email protected]
Fi
Plus a crontab can be used, this is one of the simplest backup OH
Docker Exec-i (be sure not to take-t) so the backup will be empty table, remember. See the above command introduction, Docker exec-it equivalent to open a pseudo terminal to perform the backup operation Crontab is unable to execute.
Docker containerized MySQL backup of single table data