Q & A
- 
          
 
- 
0 
 Nota
- 
0 
 Optiuni
- 
1143 
 Accesari
- 
          - CritiC 
 Shellscript for mysql database backup? 
- 4 years ago
- GNU/Linux.ro 
- 4 years ago
Here is the sample shellscript to take backup of all batabase
#!/bin/bash export DB_BACKUP="/backup/mysql_backup" export DB_USER="root" export DB_PASSWD="pass123" rm -rf $DB_BACKUP/04 # Removing oldest backup mv $DB_BACKUP/03 $DB_BACKUP/04 #moving next to oldest mv $DB_BACKUP/02 $DB_BACKUP/03 mv $DB_BACKUP/01 $DB_BACKUP/02 mkdir -p $DB_BACKUP/01 mysqldump --user=$DB_USER --password=$DB_PASSWD --all-databases | gzip > $DB_BACKUP/01/mysql-`date +%Y-%m-%d`.gz exit 0
Then add this entry to crontab to automate the task
#crontab -e 30 10 * * * /usr/bin/back_mysql.sh
This will execute everyday at 10.30
- Comenteaza
- powered by Verysign