services: fix usage of pipework
This commit is contained in:
13
package-lock.json
generated
13
package-lock.json
generated
@@ -13,7 +13,7 @@
|
||||
"@aws-sdk/lib-storage": "^3.928.0",
|
||||
"@cloudron/connect-lastmile": "^2.3.0",
|
||||
"@cloudron/manifest-format": "^5.29.0",
|
||||
"@cloudron/pipework": "^1.0.1",
|
||||
"@cloudron/pipework": "^1.2.0",
|
||||
"@cloudron/superagent": "^1.0.1",
|
||||
"@google-cloud/dns": "^5.3.1",
|
||||
"@google-cloud/storage": "^7.17.3",
|
||||
@@ -1159,10 +1159,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@cloudron/pipework": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@cloudron/pipework/-/pipework-1.0.1.tgz",
|
||||
"integrity": "sha512-T1LART+O7CoXMYDvPXVEgqtmb5d63H0wKB9jWAfjWIzqS0IOFMeawUBQaPKTO7aH8vNFEwNfU8XYK4vnJpCZ4w==",
|
||||
"license": "ISC"
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@cloudron/pipework/-/pipework-1.2.0.tgz",
|
||||
"integrity": "sha512-lD0oupEBZQycvSGMgs4JeDz40TE4pyKkw3tGFeVn72xdPAwrIXSnE/lKj/Rr1LChYSJbS14pg6AJyOddpI/hEA==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"safetydance": "^2.5.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@cloudron/superagent": {
|
||||
"version": "1.0.1",
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
"@aws-sdk/lib-storage": "^3.928.0",
|
||||
"@cloudron/connect-lastmile": "^2.3.0",
|
||||
"@cloudron/manifest-format": "^5.29.0",
|
||||
"@cloudron/pipework": "^1.0.1",
|
||||
"@cloudron/pipework": "^1.2.0",
|
||||
"@cloudron/superagent": "^1.0.1",
|
||||
"@google-cloud/dns": "^5.3.1",
|
||||
"@google-cloud/storage": "^7.17.3",
|
||||
|
||||
@@ -54,6 +54,7 @@ const addonConfigs = require('./addonconfigs.js'),
|
||||
eventlog = require('./eventlog.js'),
|
||||
fs = require('node:fs'),
|
||||
hat = require('./hat.js'),
|
||||
http = require('http'),
|
||||
infra = require('./infra_version.js'),
|
||||
logs = require('./logs.js'),
|
||||
mail = require('./mail.js'),
|
||||
@@ -1342,7 +1343,8 @@ async function backupMySql(app, options) {
|
||||
const result = await getContainerDetails('mysql', 'CLOUDRON_MYSQL_TOKEN');
|
||||
|
||||
const url = `http://${result.ip}:3000/` + (options.multipleDatabases ? 'prefixes' : 'databases') + `/${database}/backup?access_token=${result.token}`;
|
||||
const [error] = await safe(pipeRequestToFile(url, dumpPath('mysql', app.id)));
|
||||
const request = http.request(url, { method: 'POST' });
|
||||
const [error] = await safe(pipeRequestToFile(request, dumpPath('mysql', app.id)));
|
||||
if (error) throw new BoxError(BoxError.ADDONS_ERROR, `Error backing up MySQL: ${error.message}`);
|
||||
}
|
||||
|
||||
@@ -1357,7 +1359,8 @@ async function restoreMySql(app, options) {
|
||||
const result = await getContainerDetails('mysql', 'CLOUDRON_MYSQL_TOKEN');
|
||||
|
||||
const url = `http://${result.ip}:3000/` + (options.multipleDatabases ? 'prefixes' : 'databases') + `/${database}/restore?access_token=${result.token}`;
|
||||
const [error] = await safe(pipeFileToRequest(dumpPath('mysql', app.id), url));
|
||||
const request = http.request(url, { method: 'POST' });
|
||||
const [error] = await safe(pipeFileToRequest(dumpPath('mysql', app.id), request));
|
||||
if (error) throw new BoxError(BoxError.ADDONS_ERROR, `MySQL restore failed. This may require more memory. Check logs in the Services view. Details: ${error.message}`);
|
||||
}
|
||||
|
||||
@@ -1497,7 +1500,8 @@ async function backupPostgreSql(app, options) {
|
||||
const { database } = postgreSqlNames(app.id);
|
||||
|
||||
const result = await getContainerDetails('postgresql', 'CLOUDRON_POSTGRESQL_TOKEN');
|
||||
const [error] = await safe(pipeRequestToFile(`http://${result.ip}:3000/databases/${database}/backup?access_token=${result.token}`, dumpPath('postgresql', app.id)));
|
||||
const request = http.request(`http://${result.ip}:3000/databases/${database}/backup?access_token=${result.token}`, { method: 'POST' });
|
||||
const [error] = await safe(pipeRequestToFile(request, dumpPath('postgresql', app.id)));
|
||||
if (error) throw new BoxError(BoxError.ADDONS_ERROR, `Error backing up PostgreSQL: ${error.message}`);
|
||||
}
|
||||
|
||||
@@ -1511,7 +1515,8 @@ async function restorePostgreSql(app, options) {
|
||||
|
||||
const result = await getContainerDetails('postgresql', 'CLOUDRON_POSTGRESQL_TOKEN');
|
||||
|
||||
const [error] = await safe(pipeFileToRequest(dumpPath('postgresql', app.id), `http://${result.ip}:3000/databases/${database}/restore?access_token=${result.token}&username=${username}`));
|
||||
const request = http.request(`http://${result.ip}:3000/databases/${database}/restore?access_token=${result.token}&username=${username}`, { method: 'POST' });
|
||||
const [error] = await safe(pipeFileToRequest(dumpPath('postgresql', app.id), request));
|
||||
if (error) throw new BoxError(BoxError.ADDONS_ERROR, `PostgreSQL restore failed. This may require more memory. Check logs in the Services view. Details: ${error.message}`);
|
||||
}
|
||||
|
||||
@@ -1666,7 +1671,8 @@ async function backupMongoDb(app, options) {
|
||||
const database = await addonConfigs.getByName(app.id, 'mongodb', '%MONGODB_DATABASE');
|
||||
if (!database) throw new BoxError(BoxError.NOT_FOUND, 'Error backing up MongoDB. No database');
|
||||
|
||||
const [error] = await safe(pipeRequestToFile(`http://${result.ip}:3000/databases/${database}/backup?access_token=${result.token}`, dumpPath('mongodb', app.id)));
|
||||
const request = http.request(`http://${result.ip}:3000/databases/${database}/backup?access_token=${result.token}`, { method: 'POST' });
|
||||
const [error] = await safe(pipeRequestToFile(request, dumpPath('mongodb', app.id)));
|
||||
if (error) throw new BoxError(BoxError.ADDONS_ERROR, `Error backing up MongoDB: ${error.message}`);
|
||||
}
|
||||
|
||||
@@ -1683,7 +1689,8 @@ async function restoreMongoDb(app, options) {
|
||||
const database = await addonConfigs.getByName(app.id, 'mongodb', '%MONGODB_DATABASE');
|
||||
if (!database) throw new BoxError(BoxError.NOT_FOUND, 'Error restoring MongoDB. No database');
|
||||
|
||||
const [error] = await safe(pipeFileToRequest(dumpPath('mongodb', app.id), `http://${result.ip}:3000/databases/${database}/restore?access_token=${result.token}`));
|
||||
const request = http.request(`http://${result.ip}:3000/databases/${database}/restore?access_token=${result.token}`, { method: 'POST' });
|
||||
const [error] = await safe(pipeFileToRequest(dumpPath('mongodb', app.id), request));
|
||||
if (error) throw new BoxError(BoxError.ADDONS_ERROR, `MongoDB restore failed. This may require more memory. Check logs in the Services view. Details: ${error.message}`);
|
||||
}
|
||||
|
||||
@@ -1934,7 +1941,8 @@ async function backupRedis(app, options) {
|
||||
debug('Backing up redis');
|
||||
|
||||
const result = await getContainerDetails('redis-' + app.id, 'CLOUDRON_REDIS_TOKEN');
|
||||
const [error] = await safe(pipeRequestToFile(`http://${result.ip}:3000/backup?access_token=${result.token}`, dumpPath('redis', app.id)));
|
||||
const request = http.request(`http://${result.ip}:3000/backup?access_token=${result.token}`, { method: 'POST' });
|
||||
const [error] = await safe(pipeRequestToFile(request, dumpPath('redis', app.id)));
|
||||
if (error) throw new BoxError(BoxError.ADDONS_ERROR, `Error backing up Redis: ${error.message}`);
|
||||
}
|
||||
|
||||
@@ -1948,7 +1956,8 @@ async function restoreRedis(app, options) {
|
||||
debug('Restoring redis');
|
||||
|
||||
const result = await getContainerDetails('redis-' + app.id, 'CLOUDRON_REDIS_TOKEN');
|
||||
const [error] = await safe(pipeFileToRequest(dumpPath('redis', app.id), `http://${result.ip}:3000/restore?access_token=${result.token}`));
|
||||
const request = http.request(`http://${result.ip}:3000/restore?access_token=${result.token}`, { method: 'POST' });
|
||||
const [error] = await safe(pipeFileToRequest(dumpPath('redis', app.id), request));
|
||||
if (error) throw new BoxError(BoxError.ADDONS_ERROR, `Redis restore failed. This may require more memory. Check logs in the Services view. Details: ${error.message}`);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user