Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

mongo db backup node js daily

spawn = require('child_process').spawn
let backupProcess = spawn('mongodump', [
    '--db=restaurantDB',
    '--archive=.',
    '--gzip'
    ]);

backupProcess.on('exit', (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')
});
Source by dev.to #
 
PREVIOUS NEXT
Tagged: #mongo #db #backup #node #js #daily
ADD COMMENT
Topic
Name
9+6 =