docker mysql 数据库备份

backup.sh

#!/bin/bash

date=`date +%Y%m%d-%H%M%S`
dbpwd="20230101"

dbnames=("db1" "db2")
for dbname in ${dbnames[@]}
do
    docker exec mariadb mysqldump -uroot -p${dbpwd} --databases ${dbname} > /data/backup/${dbname}-${date}.sql
done
posted @ 2023-02-06 18:34  不止吧  阅读(19)  评论(0编辑  收藏  举报