Sign inSign up

shinchven/backup-mysql

By shinchven

•Updated almost 4 years ago

Image
0

55

shinchven/backup-mysql repository overview

⁠Backup MySQL

MySQL backup application with cron job.

  • Written in Node.js/TypeScript.
  • Support multiple MySQL servers and databases.
  • Dockerized.

⁠Config Before Start

Copy config-example.yml to config/config.yml and edit it.

cronTime: "*/5 * * * *"     # Cron time for backup task
defaultKeep: 7              # Default number of keep backups
outputDir: backups          # Output directory for backups
instances:                  # Instances to backup
  - host: 127.0.0.1         # Hostname or IP address of MySQL server
    port: 3306              # Port of MySQL server
    user: root              # Username of MySQL server
    password: P@ssw0rd      # Password of MySQL server
    databases:              # Databases to backup
      - name: database_name # Database name to backup
        keep: 5             # Number of keep backups for this database

Note: If the config file was changed, you should restart the application or container to reload configuration.

⁠Run as a Docker Container

⁠1. Create a docker-compose.yml file:
version: "3.8"

services:
  BackupMySQL:
    image: shinchven/backup-mysql
    container_name: backup-mysql
    restart: always
    environment:
      - TZ=Asia/Shanghai
    volumes:
      - ${PWD}/config:/usr/src/app/config   # Config file directory
      - ${PWD}/backups:/usr/src/app/backups # Backup file directory
⁠2. Deploy The container:
docker-compose up -d

⁠Run The Application Directly

⁠Prerequisites
  • Bash/Shell, Windows is not supported yet
  • MySQL Client
  • gzip
  • NodeJs
  • ts-node
⁠Run
ts-node src/index.ts

Tag summary

Content type

Image

Digest

sha256:7443eff71…

Size

176.2 MB

Last updated

almost 4 years ago

docker pull shinchven/backup-mysql