簡單的全網備份指令碼樣板

來源:互聯網
上載者:User

標籤:$?   sync   簡單   let   password   local   tar   mysql   bak   

web伺服器每天定時推送的指令碼

#!/bin/baship=`hostname -I`[ -d /backup ] || mkdir -p /backup[ -d /cup ] || mkdir -p /cup[ -d /cup/a ] || mkdir -p /cup/a##開始打包並移動\cp /var/spool/cron/root /cup/a/\cp /etc/rc.local /cup/a/\cp /etc/sysconfig/iptables /cup/a/cd /cuptar -zcf "$ip"_$(date +%F-%w)_w.tar.gz amv /cup/*.tar.gz /backupfind /backup -mtime +7 | xargs rm -rf##開始同步md5sum /backup/* > /backup/mum.md5[ $? -eq 0 ] || exiti=owhile :dorsync -avzp /backup [email protected]::backup --password-file=/etc/rsync.passwordsleep 3 let i++ [ $i -eq 2 ] && breakdone                       

備份伺服器的指令碼

#!/bin/bashbak1=/backupmontm=`date`function mon(){find /backup -name "*1_w*" | xargs -i mv {} $back1}#function lujin (){#for i in /backup/*#do# echo $i#done##}#lu=`lujin`bak1=/backupmon[ -d $back1 ] || mkdir -p $back1md5sum -c  /backup/mum.md5if [ $? -eq 0 ];then        echo "ok"else        echo "檔案推送不全" && exitfifind /backup -name "*1_w*" | xargs -i mv {} $back1find /backup/* -mtime +180 | xargs rm -rf~                                                 

inotify+rsync即時推送指令碼,樣板

#!/bin/bashPath=/databackup_Server=192.168.200.130/usr/bin/inotifywait -mrq --format ‘%w%f‘ -e create,close_write,delete /data  | while read line  do    if [ -f $line ];then        rsync -az $line --delete [email protected]$backup_Server::nfsbackup --password-file=/etc/rsync.password           else        cd $Path &&        rsync -az ./ --delete [email protected]$backup_Server::nfsbackup --password-file=/etc/rsync.password    fidone

mysql全部指令碼樣本

#!/bin/bashweek=`date +%w`yonghu=rootmima=123123dir=/datafind $dir -mtime +30 | xargs rm -rfif [ $week -eq 7 ] ;thenmysqldump -u$yongh -p$miam --opt --all-databases > $dir/mysql.all_$(date +%F).sqlfirsync -avzp $dir [email protected]192.168.200.130::mysql --password-file=/etc/rsync.password

 

簡單的全網備份指令碼樣板

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.