Database backup script

Linux

MySQL

To set up a cron job for daily database backup follow the steps mentioned below

  1. Create a backup.sh file using command - vi backup.sh
  2. On the vim, editor screen enter the command for database backup and to delete files older than 30 days


  3. Create a cron job with the command:  crontab -e

  4. This will open a crontab (cron configuration file) and the format of the job should be as follows.

    minute hour day-of-month month day-of-week <path to the backup.sh file>

    This is an example file to take database backup nightly every day at 11:59

Windows

MySQL

Need to create the task scheduler to run the backup script i.e bat file.

It will take the backup of database daily and also delete files older than 30 days


database-backup.bat