MySQLBackupScript: Difference between revisions
Jump to navigation
Jump to search
m (New page: ==The Script== <pre>#!/bin/sh USER=some_user PW=some_pw DIR=/mnt/raid5/backup/mysql echo Running: `date`; mkdir -vp $DIR; mysqldump -u$USER -p$PW --all-databases | gzip > $DIR/mysql.`ho...) |
No edit summary |
||
Line 11: | Line 11: | ||
mysqldump -u$USER -p$PW --all-databases | gzip > $DIR/mysql.`hostname`.`date +%F.%T`.sql.gz; | mysqldump -u$USER -p$PW --all-databases | gzip > $DIR/mysql.`hostname`.`date +%F.%T`.sql.gz; | ||
# | # DELETE backups older than 30 days | ||
find $DIR -type f -mtime +30 -exec rm -v {} \;</pre> | find $DIR -type f -mtime +30 -exec rm -v {} \;</pre> | ||
*Need to get pw off console command | |||
==Crontab Entry== | ==Crontab Entry== |
Revision as of 11:07, 14 December 2008
The Script
#!/bin/sh USER=some_user PW=some_pw DIR=/mnt/raid5/backup/mysql echo Running: `date`; mkdir -vp $DIR; mysqldump -u$USER -p$PW --all-databases | gzip > $DIR/mysql.`hostname`.`date +%F.%T`.sql.gz; # DELETE backups older than 30 days find $DIR -type f -mtime +30 -exec rm -v {} \;
- Need to get pw off console command
Crontab Entry
/etc/crontab;
0 4 * * * drew /home/drew/cron/mysql_backup.sh >> /home/drew/cron/mysql_backup.log;
OR
crontab -e;
0 4 * * * /home/drew/cron/mysql_backup.sh >> /home/drew/cron/mysql_backup.log;