Yarzar Tun
Yarzar Tun

Reputation: 13

How to backup mysql database every 5 miniutes automatically

I want to know ,how to backup database every 5 minutes automatically.

mysqldump -u root -p mydatabase > mydb_backup.sql

Upvotes: 1

Views: 3749

Answers (1)

Nyi Nyi
Nyi Nyi

Reputation: 966

To Make schedule db back up >>

  1. make directory with - sudo mkdir db_backup
  2. create shell script file named backup_db.sh in /var/www/dir_name and add this

    #!/bin/bash
    mysqldump -u user -p'password' db_name > /var/www/dir_name/db_backup/db_$( date +"%Y_%m_%d" ).sql
    
  3. Give the adequate permission to the that sh file with - chmod 700 backup_db.sh

  4. and then create a cron with - crontab -e and add this */5 * * * * /var/www/dir_name/backup_db.sh (Execute a cron job every 5 minutes)

Upvotes: 2

Related Questions