61 lines
1.4 KiB
TypeScript
61 lines
1.4 KiB
TypeScript
![]() |
namespace _mimir.serialization.postgresql_dump
|
||
|
{
|
||
|
|
||
|
/**
|
||
|
*/
|
||
|
export function execute(
|
||
|
parameters : _mimir.conf.type_concern_parameters_postgresql_dump,
|
||
|
directory : string
|
||
|
) : Array<string>
|
||
|
{
|
||
|
const result : Array<string> = [];
|
||
|
const password_file_path: string = "${HOME}/.pgpass";
|
||
|
result.push(
|
||
|
lib_plankton.string.coin(
|
||
|
"echo '{{host}}:{{port}}:{{schema}}:{{username}}:{{password}}' > {{path}} && chmod 0600 {{path}}",
|
||
|
{
|
||
|
"path": password_file_path,
|
||
|
"host": parameters.credentials.host,
|
||
|
"port": parameters.credentials.port.toFixed(0),
|
||
|
"username": parameters.credentials.username,
|
||
|
"password": parameters.credentials.password,
|
||
|
"schema": parameters.credentials.schema,
|
||
|
}
|
||
|
)
|
||
|
);
|
||
|
/*
|
||
|
result.push(
|
||
|
lib_plankton.string.coin(
|
||
|
"mkdir --parents {{directory}}",
|
||
|
{
|
||
|
"directory": directory
|
||
|
}
|
||
|
)
|
||
|
);
|
||
|
*/
|
||
|
result.push(
|
||
|
lib_plankton.string.coin(
|
||
|
"pg_dump --host={{host}} --port={{port}} --username={{username}} {{schema}} > {{target_path}}",
|
||
|
{
|
||
|
"host": parameters.credentials.host,
|
||
|
"port": parameters.credentials.port.toFixed(0),
|
||
|
"username": parameters.credentials.username,
|
||
|
"schema": parameters.credentials.schema,
|
||
|
"target_path": (directory + "/dump.sql"),
|
||
|
}
|
||
|
)
|
||
|
);
|
||
|
result.push(
|
||
|
lib_plankton.string.coin(
|
||
|
"rm {{path}}",
|
||
|
{
|
||
|
"path": password_file_path,
|
||
|
}
|
||
|
)
|
||
|
);
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|