Docker containerized MySQL backup of single table data

Source: Internet
Author: User
Tags mysql backup
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.