i m trying to build backup and restore feature in my app built with the MERN stack, i m trying to achieve this using mongodump and mongorestore but im facing the probleme that runing mongodump from a shell works fine but when running the same commande in nodejs i don't find any .bson i just got metadata json.
//VARIABLES
const DB_NAME = process.env.DB_NAME || "erp";
const BACKUP_DIR = process.env.BACKUP_DIR || "db_backup";
const backupDB = async (date) => {
const backupProcess = spawn("mongodump", [`--db=${DB_NAME}`, `-o=${BACKUP_DIR}/${date}`]);
backupProcess.on("close", (code, signal) => {
if (code) {
console.log("Backup process exited with code ", code);
} else if (signal) {
console.error("Backup process was killed with singal ", signal);
} else {
console.log("Successfully backedup the database");
}
});
};