mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
fix(#149): use database user in mongodump
This commit is contained in:
@@ -8,7 +8,7 @@ import { getServiceContainer } from "../docker/utils";
|
|||||||
|
|
||||||
// mongodb://mongo:Bqh7AQl-PRbnBu@localhost:27017/?tls=false&directConnection=true
|
// mongodb://mongo:Bqh7AQl-PRbnBu@localhost:27017/?tls=false&directConnection=true
|
||||||
export const runMongoBackup = async (mongo: Mongo, backup: BackupSchedule) => {
|
export const runMongoBackup = async (mongo: Mongo, backup: BackupSchedule) => {
|
||||||
const { appName, databasePassword } = mongo;
|
const { appName, databasePassword, databaseUser } = mongo;
|
||||||
const { prefix, database } = backup;
|
const { prefix, database } = backup;
|
||||||
const destination = backup.destination;
|
const destination = backup.destination;
|
||||||
const backupFileName = `${new Date().toISOString()}.dump.gz`;
|
const backupFileName = `${new Date().toISOString()}.dump.gz`;
|
||||||
@@ -23,7 +23,7 @@ export const runMongoBackup = async (mongo: Mongo, backup: BackupSchedule) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await execAsync(
|
await execAsync(
|
||||||
`docker exec ${containerId} sh -c "mongodump -d '${database}' -u 'mongo' -p '${databasePassword}' --authenticationDatabase=admin --archive=${containerPath} --gzip"`,
|
`docker exec ${containerId} sh -c "mongodump -d '${database}' -u '${databaseUser}' -p '${databasePassword}' --authenticationDatabase=admin --archive=${containerPath} --gzip"`,
|
||||||
);
|
);
|
||||||
await execAsync(`docker cp ${containerId}:${containerPath} ${hostPath}`);
|
await execAsync(`docker cp ${containerId}:${containerPath} ${hostPath}`);
|
||||||
await uploadToS3(destination, bucketDestination, hostPath);
|
await uploadToS3(destination, bucketDestination, hostPath);
|
||||||
|
|||||||
Reference in New Issue
Block a user