th?id=OHR.LandwasserViaduct_ZH-CN7692075960_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp.jpg
1、docker-composer myql 文件
mysql80:
image: mysql:8.0.16
container_name: mysql80
ports:
- "3308:3306"
environment:
- MYSQL_ROOT_PASSWORD=123456
volumes:
- /Users/docker/laradock/mysql80/conf:/etc/mysql
- /Users/docker/laradock/mysql80/data:/var/lib/mysql
networks:
- frontend
- backend
2、更换国内镜像
# 将容器中的文件拷贝出来
docker cp mysql80-xtrabackup:/etc/apt/sources.list ./
# 将修改后的文件覆盖回容器中
docker cp ./sources.list mysql80-xtrabackup:/etc/apt/
# 进入容器以后,执行下面命令更新apt信息
apt-get update
3、下载好文件percona-xtrabackup-80_8.0.13-1.buster_amd64.deb,拷贝到容器中 下载链接
# 复制进容器
docker cp ./percona-xtrabackup-80_8.0.13-1.buster_amd64.deb mysql80-xtrabackup:/root
# 安装所需依赖
apt install libev4
apt --fix-broken install
# 安装
dpkg -i percona-xtrabackup-80_8.0.13-1.buster_amd64.deb
# 安装 qpress (先去下载 然后解压 复制进容器)[qpress 安装](https://www.cnblogs.com/abclife/p/7568345.html)
docker cp ./qpress mysql80-xtrabackup:/usr/bin/
4、解包
cat hins13423453_data_20200727054807_qp.xb | xbstream -x -v -C /etc/mysql/backup/data
5、解压
xtrabackup --decompress --remove-original --target-dir=/etc/mysql/backup/data
6、恢复解压好的备份文件。
xtrabackup --prepare --target-dir=/etc/mysql/backup/data
7、复制文件到 /var/lib/mysql(我复制报 empty错误,先清空/var/lib/mysql 目录 然后把恢复好的那个复制过去就行)
xtrabackup --datadir=/var/lib/mysql --copy-back --target-dir=/etc/mysql/backup/data
8、修改 my.cnf 新增
lower_case_table_names = 1
9、重启mysql服务
# 重启docker 容器就行,密码是备份那个数据库的密码
阿里云文档
qpress 安装
MySQL数据库备份实操