It's about to create auto backup mysql on Mandriva 2005 (Linux) server.
1. Create file backup.sh, you may using mc or pico
$ mcedit /backup.sh
File content :
#! /bin/sh /usr/bin/mysqldump -u[username] -p[password] [database_name] > /[your_backup_directory]/[filename].sql cd /backup tar --remove-files -czf backup-`date '+%Y-%m-%d' `.tar.gz -R *.sql sudo cp -f *.tar.gz /[another_backup_directory]
2. Edit your cron list
$ mcedit /etc/crontab
File content :
SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ # run-parts 00 7-14 * * 1-6 root /bin/sh /backup.sh
3. Reconfigure your crontab
$ crontab -u[username] /etc/crontab $ crontab -l
MySQL auto backup scheduled every Monday through Friday beginning at 7 am till 2 pm :)
0 comments:
Posting Komentar