Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////////////////////////////////////////////////
- // Run: 'gulp download-db' to get latest SQL dump from production //
- // File will be put under the 'dumps' folder //
- ////////////////////////////////////////////////////////////////////
- // Load stuff
- 'use strict'
- var gulp = require('gulp')
- var GulpSSH = require('gulp-ssh')
- var fs = require('fs');
- // Function to get home path
- function getUserHome() {
- return process.env.HOME || process.env.USERPROFILE;
- }
- var homepath = getUserHome();
- ///////////////////////////////////////
- // SETTINGS (change if needed) //
- ///////////////////////////////////////
- var config = {
- // SSH connection
- host: '1.2.3.4',
- port: 22,
- username: 'ubuntu',
- //password: '1337p4ssw0rd', // Uncomment if needed
- privateKey: fs.readFileSync( homepath + '/certs/somecert.pem'), // Uncomment if needed
- // MySQL connection
- db_host: 'localhost',
- db_name: 'clients_db',
- db_username: 'root',
- db_password: 'dbp4ssw0rd',
- }
- ////////////////////////////////////////////////
- // Core script, don't need to touch from here //
- ////////////////////////////////////////////////
- // Set up SSH connector
- var gulpSSH = new GulpSSH({
- ignoreErrors: true,
- sshConfig: config
- })
- // Run the mysqldump
- gulp.task('download-db', function(){
- return gulpSSH
- // runs the mysql dump
- .exec(['mysqldump -u '+config.db_username+' -p\''+config.db_password+'\' -h '+config.db_host+' '+config.db_name+''], {filePath: 'dump.sql'})
- // pipes output into local folder
- .pipe(gulp.dest('dumps'))
- })
- // Run search/replace "optional"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement