tasks/deployments.js
function db_dump(config, output_paths) {

        var cmd;

        grunt.file.mkdir(output_paths.dir);


        // 2) Compile MYSQL cmd via Lo-Dash template string
        var tpl_mysqldump = grunt.template.process(tpls.mysqldump, {
            data: {
                user: config.user,
                pass: config.pass,
                database: config.database,
                host: config.host
            }
        });


        // 3) Test whether MYSQL DB is local or whether requires remote access via SSH
        if (typeof config.ssh_host === "undefined") { // it's a local connection
            grunt.log.writeln("Creating DUMP of local database");
            cmd = tpl_mysqldump;

        } else { // it's a remote connection
            var tpl_ssh = grunt.template.process(tpls.ssh, {
                data: {
                    host: config.ssh_host
                }
            });
            grunt.log.writeln("Creating DUMP of remote database");

            cmd = tpl_ssh + " \\ " + tpl_mysqldump;
        }

        // Capture output...
        var output = shell.exec(cmd, {silent: true}).output;

        // Write output to file using native Grunt methods
        grunt.file.write( output_paths.file, output );

        grunt.log.oklns("Database DUMP succesfully exported to: " + output_paths.file);

    }
function db_dump(config, output_paths) {

        var cmd;

        grunt.file.mkdir(output_paths.dir);


        // 2) Compile MYSQL cmd via Lo-Dash template string
        var tpl_mysqldump = grunt.template.process(tpls.mysqldump, {
            data: {
                user: config.user,
                pass: config.pass,
                database: config.database,
                host: config.host
            }
        });


        // 3) Test whether MYSQL DB is local or whether requires remote access via SSH
        if (typeof config.ssh_host === "undefined") { // it's a local connection
            grunt.log.writeln("Creating DUMP of local database");
            cmd = tpl_mysqldump;

        } else { // it's a remote connection
            var tpl_ssh = grunt.template.process(tpls.ssh, {
                data: {
                    host: config.ssh_host
                }
            });
            grunt.log.writeln("Creating DUMP of remote database");

            cmd = tpl_ssh + " \\ " + tpl_mysqldump;
        }

        // Capture output...
        var output = shell.exec(cmd, {silent: true}).output;

        // Write output to file using native Grunt methods
        grunt.file.write( output_paths.file, output );

        grunt.log.oklns("Database DUMP succesfully exported to: " + output_paths.file);

    }
function db_dump ( config , output_paths ) { var cmd ; grunt . file . mkdir ( output_paths . dir ) ; // 2) Compile MYSQL cmd via Lo-Dash template string var tpl_mysqldump = grunt . template . process ( tpls . mysqldump , { data : { user : config . user , pass : config . pass , database : config . database , host : config . host } } ) ; // 3) Test whether MYSQL DB is local or whether requires remote access via SSH if ( typeof config . ssh_host === "undefined" ) { // it's a local connection grunt . log . writeln ( "Creating DUMP of local database" ) ; cmd = tpl_mysqldump ; } else { // it's a remote connection var tpl_ssh = grunt . template . process ( tpls . ssh , { data : { host : config . ssh_host } } ) ; grunt . log . writeln ( "Creating DUMP of remote database" ) ; cmd = tpl_ssh + " \\ " + tpl_mysqldump ; } // Capture output... var output = shell . exec ( cmd , { silent : true } ) . output ; // Write output to file using native Grunt methods grunt . file . write ( output_paths . file , output ) ; grunt . log . oklns ( "Database DUMP succesfully exported to: " + output_paths . file ) ; }
Dumps a MYSQL database to a suitable backup location
Dumps a MYSQL database to a suitable backup location