/database-and-server-backup

Backup database and server

Primary LanguageJavaScriptMIT LicenseMIT

database-and-server-backup

npm license

Backup database and server.

Usage

Make sure:

  1. You have SSH login without password.
  2. You have mysql-client installed and mysqldump command is running on terminal. (In Linux sudo apt-get install mysql-client)

Install library to your project with yarn or npm.

yarn add database-and-server-backup
npm i database-and-server-backup

Import library to your JS file.

const backup = require('database-and-server-backup')

Create a config object.

const config = {
  mysql: ['-u', 'yourUsername', '--password=yourPassword', '-h', 'yourIp', 'yourDatabaseName'],
  server: 'yourUsername@yourIp:/your/folder',
  backupFolder: '/home/user/full/path'
}

Pass config object to the backup function.

backup(config)
  .then(() => {
    // done
  })
  .catch((err) => {
    console.log(err)
  })

Run the script.

node file.js

License

MIT