查看运行的容器:
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
991819540cb9 odoo:12.0 "/entrypoint.sh odoo" 8 weeks ago Up 8 days 8071-8072/tcp, 0.0.0.0:8010->8069/tcp, :::8010->8069/tcp odoo-docker_web_1
c7fd60695383 postgres:10 "docker-entrypoint.s…" 8 weeks ago Up 5 weeks 0.0.0.0:5454->5432/tcp, :::5454->5432/tcp odoo-docker_db_1
进入目标容器:
docker exec -u root -it 容器名 /bin/bash
示例:docker exec -u root -it c7fd /bin/bash
docker 中,以root用户,创建备份目录,直接执行如下命令,
pg_dump -h localhost -p 5432 -U odoo xxx(数据库名) > /数据库dump备份文件目录/dump_XXX(数据库名)_bak_20220203.sql
示例:pg_dump -h localhost -p 5432 -U odoo GDXF > dump_GDXF_bak_20220203.sql
示例中的备份文件没有使用备份目录,代表备份文件dump_GDXF_bak_20220203.sql保存到本地目录中。
root@c7fd60695383:/
bin boot dev docker-entrypoint-initdb.d docker-entrypoint.sh dump_GDXF_bak_20220203.sql etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
退出容器
root@c7fd60695383:/
root@kib8dt8iltxoq:~
将docker容器里备份文件复制到宿主机:
root@kib8dt8iltxoq:~
注意:这里的容器ID要完整的
|