@ps-aux/nodebup 0.9.7 → 0.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -27,7 +27,7 @@ const parseConnectionUrl = url => {
|
|
|
27
27
|
var _url$match;
|
|
28
28
|
|
|
29
29
|
// TODO what if there are query params in the end?
|
|
30
|
-
const regex = /postgres:\/\/(?<username>.*):(?<password>.*)@(?<host>.*):(?<port>\d*)
|
|
30
|
+
const regex = /postgres:\/\/(?<username>.*):(?<password>.*)@(?<host>.*):(?<port>\d*)$/;
|
|
31
31
|
const match = (_url$match = url.match(regex)) === null || _url$match === void 0 ? void 0 : _url$match.groups;
|
|
32
32
|
if (!match || !match.username || !match.password || !match.host || !match.port) throw new Error(`The Postgres connection URL does not match required regex: ${regex.toString()}`);
|
|
33
33
|
return {
|
|
@@ -103,7 +103,7 @@ let PgBackupController = (_dec = (0, _inversify.injectable)(), _dec2 = Reflect.m
|
|
|
103
103
|
const version = this.getVersion(pgVersion);
|
|
104
104
|
const storage = this.storageBackendProvider.provide(); // To validate
|
|
105
105
|
|
|
106
|
-
parseConnectionUrl(pgUrl);
|
|
106
|
+
const con = parseConnectionUrl(pgUrl);
|
|
107
107
|
this.log.info(`Restoring Postgres database, version=${version}`);
|
|
108
108
|
await this.fs.inTmpDir('pg-restore', async dirStr => {
|
|
109
109
|
const dir = _Path.AbsPath.from(dirStr);
|
|
@@ -115,10 +115,13 @@ let PgBackupController = (_dec = (0, _inversify.injectable)(), _dec2 = Reflect.m
|
|
|
115
115
|
await this.zip.unzipDir(zipFile, dir);
|
|
116
116
|
this.fs.rmFile(zipFile);
|
|
117
117
|
const outFile = this.fs.listFiles(dir)[0];
|
|
118
|
-
this.log.debug('Will run psql import from %s', outFile.str()); //
|
|
118
|
+
this.log.debug('Will run psql import from %s', outFile.str()); // Database is set to 'postgres' so that also users which don't have db created can use db-less URL
|
|
119
|
+
// Restoring user needs to have the admin access anyway
|
|
120
|
+
|
|
121
|
+
const connectionArgs = `-h ${con.host} -p ${con.port} -U ${con.username} -d postgres`; // Don't forget that this itself might be run in docker
|
|
119
122
|
// therefore volume mounts are not usable (will apply to the location at host)
|
|
120
123
|
|
|
121
|
-
this.sh.exec(`docker run --network host -i ` + `postgres:${version} ` + `psql ${
|
|
124
|
+
this.sh.exec(`docker run --network host -i ` + `-e PGPASSWORD=${con.password} ` + `postgres:${version} ` + `psql ${connectionArgs} -v ON_ERROR_STOP=0 < ${outFile.str()}`);
|
|
122
125
|
});
|
|
123
126
|
});
|
|
124
127
|
}
|
|
@@ -26,7 +26,8 @@ let Zipper = (_dec = (0, _inversify.injectable)(), _dec(_class = class Zipper {
|
|
|
26
26
|
_defineProperty(this, "log", (0, _logging.classObjLog)(this));
|
|
27
27
|
|
|
28
28
|
_defineProperty(this, "zipDir", async (dir, to) => {
|
|
29
|
-
this.log.trace(`Zipping %s to %s`, dir.str(), to.str());
|
|
29
|
+
this.log.trace(`Zipping %s to %s`, dir.str(), to.str()); // TODO replace with unzipper
|
|
30
|
+
|
|
30
31
|
const z = new _admZip.default();
|
|
31
32
|
z.addLocalFolder(dir.str());
|
|
32
33
|
z.writeZip(to.str());
|