#!/usr/bin/awk -f BEGIN { # Created by James Li # 2011/10/21 # Backup all database. tmp_country="ar:au:br:ca:carib:cn:cz:de:dk:es:eu:fr:hu:in:it:jp:kr: latam:mea:mx:my:nl:pl:pt:rs:ru:th:tr:tw:ua:uk:us:vn:www" db_dir = "/mysql/" tar_dir = "/home/backup/mysql/" split(tmp_country, country, ":") for ( i in country ) { tmp_db = db_dir country[i] "_db" tmp_tar = tar_dir country[i] "_db.tar.gz" cmd = "tar -zcvf " tmp_tar " " tmp_db system(cmd) } }
基本使用上很像PHP, 但還是花了一點時間研究, 只是為了能快速完成工作, 所以只寫這樣.