GitHub - null4bl3/sqldumper: SQL dump auto mailer for Linux using node.js and bash. ( Free / paid Mailjet account required )

2 min read Original article ↗

SQLDUMPER

SQL dump auto mailer for Linux using node.js and bash.

The script runs on a system using node-cron to trigger a bash script in a node.js child_process, the bash script creates a MySQL dump of a database and mails the file to the recipients of your choice.

Requirements

A mailjet account.

Installation

git clone https://github.com/null4bl3/sqldumper
cd sqldumper
npm install

Configuration

This project needs a file called "config.json" in the root of the project directory.

The config file should contain the following parameters:

{
  "PROJECT": "",
  "DATABASE": {
    "DB": "",
    "USER": "",
    "PASS": ""
  },
  "MAILJET": {
    "MAILFROM": "",
    "MAILTO": [
      {
        "Email": "",
        "Name": ""
      }
    ],
    "PUBKEY": "",
    "SECRET": ""
  },
  "CRON": ""
}

PROJECT - The project name. Used for file naming.

DATABASE.DB - The database to create a dump from

DATABASE.USER - The database user

DATABASE.PASS - The database password

MAILJET.MAILFROM - A string containing the email of a an approved mailjet email.

MAILJET.MAILTO - An array of objects of recipients contacts with Name and Email values

MAILJET.PUBKEY - The mailjet public key

MAILJET.SECRET - The mailjet secret

CRON - A node-cron string structured as: 0 0 0 * * *

( this example runs every day at midnight )

The application uses npm run script functionality, meaning that to start the application daemonized run:

And to stop: