MySQL CRON Backup with file date named
Par Arnaud Charlier, mardi 26 février 2008 à 02:56 :: Linux et Debian :: #37 :: rss
This is a fast and easy way to backup MySQL DB every N-Time.
This solution is based on Shell, mysqldump command and CRON deamon
First create a file called
#! /bin/sh DATE=$(date +%d-%m-%Y_%H_%M) /usr/bin/mysqldump -uuser -ppassword -l -q --add-drop-table dbname > /home/myuser/backup/fileName$(DATE).sql
- First line declare place of shell executing command
- Second line build a variable date with the system current date (day on 2 char, month on 2 number, Year on 4 char, Hours, Minutes)
- Then we launch the mysqldump command with full path to it, passing mysql user param and password, name of DB to save and then the path to save it.
The file name is build on DATE var value, declared on line 2.
Then we simply need to execute this file by cron with time value to execute it in determined interval
Commentaires
Aucun commentaire pour le moment.
Ajouter un commentaire
Les commentaires pour ce billet sont fermés.