Daily automatic backup of MySQL database by cron job
Before you continue, ensure you meet the following requirements:
- You are using a Linux.
sudo mysql
or
mysql -u root -p
GRANT LOCK TABLES, SELECT ON DATABASE_NAME.* TO ‘NAME’_USER@‘localhost' IDENTIFIED BY ‘PASSWORD’;
FLUSH PRIVILEGES;
cd ~
mkdir Database_Backup
touch db_backup.sh
nano db_backup.sh
sudo chmod 700 db_backup.sh
touch db_backup.log
sudo chmod 700 db_backup.log
(At 00:11 daily)
crontab -e
11 00 * * * /home/db_backup.sh