1

使用 docker 备份 mysql 数据库内容

 2 years ago
source link: https://www.lfhacks.com/tech/docker-dump-mysql
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

使用 docker 备份 mysql 数据库内容

1345.jpg

假设你有一个数据库,需要在另一台主机上定时启动备份任务,但是这台主机上没有 mysqldump 命令,我们可以启动一个 mysql 镜像来备份。

使用命令格式如下:

$ docker run --rm mysql:5.7 \
  /usr/bin/mysqldump -h ${db_host} -u ${db_user} --password=${db_pass} ${db_name} \
  > /backup/${db_name}_`date "+%y%m%d-%H%M%S"`.sql

坚持原创不易。如果您觉得有收获,请考虑资助本站,以期待更多原创文章。

打赏作者,支持小站

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK