RSS   



  可打印版本 | 推薦給朋友 | 訂閱主題 | 收藏主題 | 純文字版  


 


 
主題: [分享]備份心得記錄   字型大小:||| 
MU
版主
等級: 30等級: 30等級: 30等級: 30等級: 30等級: 30等級: 30等級: 30
驢的傳人-驢騎士

今日心情

 . 積分: 765
 . 精華: 12
 . 文章: 5247
 . 收花: 3150 支
 . 送花: 1996 支
 . 比例: 0.63
 . 在線: 609 小時
 . 瀏覽: 6090 頁
 . 註冊: 7243
 . 失蹤: 80
 . 台中的阿土伯
#1 : 2008-10-13 09:26 PM     只看本作者 引言回覆

#!/bin/bash
#
# This program is created by VBird 2002/06/13
#
# What is this program?
#       This program will backup the following messages:
#       1. MySQL data files ( /var/lib/mysql );
#       2. HTTP's CGI-directory ( /var/www/cgi-bin )
#
# HOW TO RUN THIS PROGRAM?
#       Just put the file into /etc/crontab job,
#       or put this file's link file to /etc/cron.daily!
#
###############################################################
# History
#  Date         What                                    Who
#==============================================================
# 2002/06/13    First time to run this program
#               The only backup files are MySQL and CGI VBird
#==============================================================
# 0. Get the date messages and backup directory
day=`date +%Y-%m-%d`
backup_dir="/home/scn/disk2/backup/daily"

#!欲備份的目錄
#dir1="/var/www/html/sfs3"
dir2="/var/lib/mysql/sfs3"

#!備份後的檔名
#targetfile1="sfs3html-"`date '+%y-%m-%d'`.tar.gz
targetfile2="sfs3data-"`date '+%y-%m-%d'`.tar.gz

#!執行tar打包
#tar zcvf $backup_dir/$targetfile1 $dir1
tar zcvf $backup_dir/$targetfile2 $dir2

#!mysql資料庫資訊
databasename="sfs3"
rootpassword="scl0380"

#!sql匯出後的檔名
sqlfilename="sfs3sql-"`date '+%y-%m-%d'`.sql

#!以root身份利用mysqldump指令匯出sfs3資料庫資料
mysqldump $databasename > $backup_dir/$sqlfilename -uroot -p$rootpassword

#!zip壓縮匯出檔

zip $backup_dir/$sqlfilename.zip $backup_dir/$sqlfilename

#!只保留zip檔請執行下列指令 不刪除請保留#
rm -rf $backup_dir/$sqlfilename


#!切換到存放目錄
cd $backup_dir


#!設定ftp帳號密碼與存放目錄
host="172.16.0.2"
user="administrator"
password="nt6908"
replace_dir="daily"


#!啟動ftp連接

ftp -in << EOF
open $host
user $user $password
cd $replace_dir
bin
put $targetfile2
put $sqlfilename.zip
EOF



[如果你喜歡本文章,就按本文章之鮮花~送花給作者吧,你的支持就是別人的動力來源]
本文連接  
檢閱個人資料  發私人訊息  Blog  快速回覆 新增/修改 爬文標記
MU
版主
等級: 30等級: 30等級: 30等級: 30等級: 30等級: 30等級: 30等級: 30
驢的傳人-驢騎士

今日心情

 . 積分: 765
 . 精華: 12
 . 文章: 5247
 . 收花: 3150 支
 . 送花: 1996 支
 . 比例: 0.63
 . 在線: 609 小時
 . 瀏覽: 6090 頁
 . 註冊: 7243
 . 失蹤: 80
 . 台中的阿土伯
#2 : 2008-10-13 09:28 PM     只看本作者 引言回覆

#!/bin/bash
#
# This program is created by VBird 2002/06/13
#
# What is this program?
#       This program will backup the following messages:
#       1. MySQL data files ( /var/lib/mysql );
#       2. HTTP's CGI-directory ( /var/www/cgi-bin )
#
# HOW TO RUN THIS PROGRAM?
#       Just put the file into /etc/crontab job,
#       or put this file's link file to /etc/cron.daily!
#
###############################################################
# History
#  Date         What                                    Who
#==============================================================
# 2002/06/13    First time to run this program
#               The only backup files are MySQL and CGI VBird
#==============================================================
# 0. Get the date messages and backup directory
day=`date +%Y-%m-%d`
backup_dir="/home/scn/disk2/backup/weekly"

#!欲備份的目錄
dir1="/var/www/html/sfs3"
#dir2="/var/lib/mysql/sfs3"

#!備份後的檔名
targetfile1="sfs3html-"`date '+%y-%m-%d'`.tar.gz
#targetfile2="sfs3data-"`date '+%y-%m-%d'`.tar.gz

#!執行tar打包
tar zcvf $backup_dir/$targetfile1 $dir1
#tar zcvf $backup_dir/$targetfile2 $dir2

#!mysql資料庫資訊
#databasename="sfs3"
#rootpassword="scl0380"

#!sql匯出後的檔名
#sqlfilename="sfs3sql-"`date '+%y-%m-%d'`.sql

#!以root身份利用mysqldump指令匯出sfs3資料庫資料
#mysqldump $databasename > $backup_dir/$sqlfilename -uroot -p$rootpassword

#!zip壓縮匯出檔

#zip $backup_dir/$sqlfilename.zip $backup_dir/$sqlfilename

#!只保留zip檔請執行下列指令 不刪除請保留#
#rm -rf $backup_dir/$sqlfilename


#!切換到存放目錄
cd $backup_dir


#!設定ftp帳號密碼與存放目錄
host="172.16.0.2"
user="administrator"
password="nt6908"
replace_dir="weekly"


#!啟動ftp連接

ftp -in << EOF
open $host
user $user $password
cd $replace_dir
bin
put $targetfile1

EOF



[如果你喜歡本文章,就按本文章之鮮花~送花給作者吧,你的支持就是別人的動力來源]
本文連接  
檢閱個人資料  發私人訊息  Blog  快速回覆 新增/修改 爬文標記
azactam
銅驢友〔初級〕
等級: 8等級: 8


今日心情

 . 積分: 128
 . 文章: 230
 . 收花: 630 支
 . 送花: 7604 支
 . 比例: 12.07
 . 在線: 2779 小時
 . 瀏覽: 49137 頁
 . 註冊: 7058
 . 失蹤: 11
#3 : 2008-10-15 03:27 PM     只看本作者 引言回覆

最近公司在搞資安,小小建議樓主把跟password有關的部份改成****比較安全喔!!


[如果你喜歡本文章,就按本文章之鮮花~送花給作者吧,你的支持就是別人的動力來源]
本文連接  
檢閱個人資料  發私人訊息  Blog  快速回覆 新增/修改 爬文標記

   

快速回覆
表情符號

更多 Smilies

字型大小 : |||      [完成後可按 Ctrl+Enter 發佈]        

溫馨提示:本區開放遊客瀏覽。
選項:
關閉 URL 識別    關閉 表情符號    關閉 Discuz! 代碼    使用個人簽名    接收新回覆信件通知
發表時自動複製內容   [立即複製] (IE only)


 



所在時區為 GMT+8, 現在時間是 2024-4-27 04:25 AM
清除 Cookies - 連絡我們 - TWed2k © 2001-2046 - 純文字版 - 說明
Discuz! 0.1 | Processed in 0.019268 second(s), 6 queries , Qzip disabled