Automatic MySQL Backup shell script


shell scripts นี้เขียนดีกว่าที่ผมเขียน...ใชัอันนี้เลยดีกว่า

Automatic MySQL Backup เป็น Shell scripts ที่ช่วยในการ backup ฐานข้ัอมูล MySQL มีความสามารถดังนี้

 

  • Backup mutiple MySQL databases with one script. (Now able to backup ALL databases on a server easily. no longer need to specify each database seperately)
  • Backup all databases to a single backup file or to a seperate directory and file for each database.
  • Automatically compress the backup files to save disk space using either gzip or bzip2 compression.
  • Can backup remote MySQL servers to a central server.
  • Runs automatically using cron or can be run manually.
  • Can e-mail the backup log to any specified e-mail address instead of "root". (Great for hosted websites and databases).
  • Can email the compressed database backup files to the specified email address.
  • Can specify maximun size backup to email.
  • Can be set to run PRE and POST backup commands.
  • Choose which day of the week to run weekly backups.

 วิธีใช้งานแสนง่าย download automysqlbackup.sh มา
แล้ว config อีกเล็กน้อย ดังนี้

USERNAME=root
PASSWORD=mypassword
DBHOST=localhost
DBNAMES="db1 db2 db3" # แต่ถ้าใส่เป็น all  จะหมายถึง backup ทุก database
BACKUPDIR="/backup"

สุดท้ายก็อย่าลืมกำหนด execute permission ให้มันด้วย chmod +x automysqlbackup.sh

หลังจากสั่งงานแล้ว shell script จะสร้าง directory เพิ่มให้ (ถ้ายังไ่่ม่มี) ดังนี้

/backup/daily
/backup/monthly
/backup/weekly

 แล้ว scripts จะจัดการเรื่องของไฟล์ให้เอง (rotation)

โอเค ขว้างของเดิมทิ้ง shell scripts นี้เขียนดีกว่าที่ผมเขียน...ใชัอันนี้เลยดีกว่า

ขอบคุณ คุณ wipe_out ผู้เขียน scripts นี้มา ณ ที่นี่ด้วยครับ
Thank you 'wipe_out' for your scripts!

 

หมายเลขบันทึก: 146873เขียนเมื่อ 16 พฤศจิกายน 2007 13:43 น. ()แก้ไขเมื่อ 14 มิถุนายน 2012 11:26 น. ()สัญญาอนุญาต: จำนวนที่อ่านจำนวนที่อ่าน:


ความเห็น (0)

ไม่มีความเห็น

พบปัญหาการใช้งานกรุณาแจ้ง LINE ID @gotoknow
ClassStart
ระบบจัดการการเรียนการสอนผ่านอินเทอร์เน็ต
ทั้งเว็บทั้งแอปใช้งานฟรี
ClassStart Books
โครงการหนังสือจากคลาสสตาร์ท