You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`DB_EXPORT_GZIP=true`: Compress the sql file using Gzip (optional)
61
+
-`DB_EXPORT_GZIP=true`: Compress the sql file using Gzip (optional). If `false` or not defined then the exported file will be a `.sql` file.
62
+
-`DB_ARGS`: can be used in order to pass more `mysqldump` arguments (optional).
63
+
- An `.env` example file can be found at [./mysql_exporter.env](./mysql_exporter.env)
58
64
59
-
#### Export database using a Docker container
65
+
#### Exporting a database using a Docker container
66
+
67
+
The following Docker commands create a container in order to export a database and then remove such container automatically.
68
+
69
+
**Note:**`mysql_exporter` supports enviroment variables or a `.env` file passed as argument.
60
70
61
71
```sh
62
72
docker run --rm -it \
63
-
--name joseluisq/alpine-mysql-client \
64
-
--volume $(PWD):/root/sample \
65
-
--workdir /root/sample \
66
-
joseluisq/alpine-mysql-client \
67
-
mysql_exporter .env
73
+
--volume $(PWD):/home/mysql/sample \
74
+
--workdir /home/mysql/sample \
75
+
joseluisq/alpine-mysql-client:1 \
76
+
mysql_exporter production.env
77
+
78
+
# Alpine / MySQL Client - Exporter
79
+
# ================================
80
+
# mysqldump Ver 10.17 Distrib 10.4.12-MariaDB, for Linux (x86_64)
81
+
# Exporting database `mydb` to `mydb.sql.gz` file...
82
+
# Database `mydb` was exported successfully!
83
+
# 2.0M mydb.sql.gz
68
84
```
69
85
70
-
__Note:__`.env` is a custom file with the corresponding environment variables passed as argument.
86
+
__Notes:__
87
+
88
+
-`--volume $(PWD):/home/mysql/sample` specificy a [bind mount directory](https://docs.docker.com/storage/bind-mounts/) from host to container.
89
+
-`$(PWD)` is just my host working directory. Use your own path.
90
+
-`/home/mysql/` is default home directory user (optional). View [User privileges](#user-privileges) section above.
91
+
-`/home/mysql/sample` is a container directory that Docker will create for us.
92
+
-`--workdir /home/mysql/sample` specificy the working directory used by default inside the container.
93
+
-`production.env` is a custom env file path with the corresponding environment variables passed as argument. That file shoud available in your host working directory. E.g `$PWD` in my case.
94
+
95
+
#### Exporting a database using a Docker compose file
96
+
97
+
```yaml
98
+
version: "3.3"
99
+
100
+
services:
101
+
exporter:
102
+
image: joseluisq/alpine-mysql-client:1
103
+
env_file: .env
104
+
command: mysql_exporter
105
+
working_dir: /home/mysql/sample
106
+
volumes:
107
+
- ./:/home/mysql/sample
108
+
networks:
109
+
- default
110
+
```
111
+
112
+
## Contributions
113
+
114
+
Feel free to send a [pull request](https://github.com/joseluisq/alpine-mysql-client/pulls) or file some [issue](https://github.com/joseluisq/alpine-mysql-client/issues).
0 commit comments