- #date +%Y%m%d-%H%M --->要用日期做檔名
- #tar cvfz `date +%Y%m%d-%H%M`.tar.gz /home
- 在備份完成後建立新檔案,做一個時間戳記
- #touch /home/timemark
- 找出比timemark更晚建立的檔案
- #find /home -newer timemark
- 建立新備份
- #tar cvfz `date +%Y%m%d-%H%M`.tar.gz `find /home -newer timemark`
- 以上寫成.sh檔案,放到crontab就可以每天自動執行了
serverA利用public/privare key來保障傳送備份資料到 serverB的安全
1.需要什麼服務?可以利用ssh/scp2.如何全自動?寫成shell script
serverA
- 建立key
- #ssh-keygen -t rsa
- Generating public/private rsa key pair.
- Enter file in which to save the key (/root/.ssh/id_rsa): --->把key放這
- Created directory '/root/.ssh'.
- Enter passphrase (empty for no passphrase):--->輸入key的密碼(空白也可)
- Enter same passphrase again:
- Your identification has been saved in /root/.ssh/id_rsa.
- Your public key has been saved in /root/.ssh/id_rsa.pub.
- The key fingerprint is:
- f6:32:90:e2:e7:03:c8:c1:a4:99:0b:3e:a1:73:3c:48 root@localhost.localdomain
- 傳送public key到serverB的家目錄
- #cd /root/.ssh
- #scp id_rsa.pub root@serverBIP:~/
- #cd~
- #mkdir /root/.ssh
- #cat id_rsa.pub >> .ssh/authorized_keys
如果有問題可檢查log
/var/log/secure
沒有留言:
張貼留言