db_backup.sh檔案內容:
#!/bin/sh . ~/.bashrc for DB in db1 db2 db3 do DATE=`date +%Y-%m-%d` HOST="xxx.xxx.xxx.xxx" DEST=/db_backup/${HOST}_mysql_dump_${DB}_${DATE}.sql ### dump db mysqldump --user=<username>--password=<password> --host=${HOST} --databases ${DB} > $DEST ### compress dump files gzip $DEST done設定該Shell可以運行
chmod 755 db_backup.sh ./db_backup.sh
0 意見:
張貼留言