Giter Site home page Giter Site logo

mysql-backup's Introduction

# Database Backup Script

This script is designed to perform regular backups of MySQL databases using Node.js. It utilizes \`node-cron\` for scheduling and \`mysqldump\` for generating SQL dump files.

## Prerequisites

Ensure you have the following dependencies installed:

- Node.js
- npm (Node Package Manager)
- MySQL server

## Installation

1. Clone this repository to your local machine:

   ```bash
   git clone https://github.com/your/repository.git
   ```

2. Navigate to the project directory:

   ```bash
   cd project-directory
   ```

3. Install required npm packages:

   ```bash
   npm install
   ```

## Configuration

Before running the script, make sure to set the following environment variables:

- \`DB_HOST\`: MySQL host address
- \`DB_USER\`: MySQL username
- \`DB_PASSWORD\`: MySQL password

## Usage

To start the backup process, run the following command:

```bash
node backup.js
```

The script will execute at regular intervals (every minute by default) and create backup files for each database (excluding default ones like \`information_schema\`, \`mysql\`, and \`performance_schema\`) in the \`./db_backup\` directory.

## Customization

You can customize the backup schedule by modifying the cron expression:

```javascript
cron.schedule("* * * * *", () => {
  performBackup();
});
```

The above expression runs the backup process every minute. You can adjust it as per your requirement using the cron syntax.

## Note

- Make sure the MySQL server is running and accessible from the host where the script is executed.
- Ensure proper permissions are set for accessing and writing backup files.

## License

This script is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
`

mysql-backup's People

Contributors

popat694 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.