答案 0 :(得分:3)
There are basically three ways to restore a dump file to a database running inside azk
(they also work with other DBs such as MySQL and MariaDB):
1- Using a local client (graphical tool or command line tool):
Before connecting to the database, you need to find out the database running port:
$ azk start postgres # Ensures the database is running
$ azk status postgres
┌───┬──────────┬───────────┬──────────────┬─────────────────┬─────────────┐
│ │ System │ Instances │ Hostname/url │ Instances-Ports │ Provisioned │
├───┼──────────┼───────────┼──────────────┼─────────────────┼─────────────┤
│ ↑ │ postgres │ 1 │ dev.azk.io │ 1-data:32831 │ - │
└───┴──────────┴───────────┴──────────────┴─────────────────┴─────────────┘
Now, we can connect to the database using the host dev.azk.io
and the resulting port from the previous command (32381
). The username, password and database name are defined in the Azkfile
.
2- Using azk shell
and the database CLI:
Running the same steps described above to find out the database running port, you can run the following command:
$ azk shell postgres
$ psql --host dev.azk.io --port 32831 --username ${POSTGRES_USER} \
--password=${POSTGRES_PASS} --dbname=${POSTGRES_DB} < dbexport.sql
3 - Using autoload script from the database image:
Most of the official Docker Images for databases has an entrypoint
script, which looks for files in the folder /docker-entrypoint-initdb.d/
and run them when the database is initialized. Given that, you can simply mount your dump files (.sql
) in that location, like described in the following Azkfile
:
systems({
postgres: {
image: { docker: "azukiapp/postgres" },
mounts: {
"/docker-entrypoint-initdb.d": sync("./dumps"),
}
}
});
Starting the postgres
system with the command azk start postgres
, the dump files will be run automatically.
Obs: As you can see in the Postgres' script and in the Mysql's, the dump files can be plain text (.sql
), compressed (.sql.gz
) or even shell scripts (.sh
).
答案 1 :(得分:1)
我只是在PR中添加了图像存储库中的说明:
部分