Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Backing up windows share files for the most recent day

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

#! / bin/bash

Src=/root/server/ic/

Dst=/var/server_data/ic/

DateTime= `date +% Y%m%d-%H:% M`

Mount-t cifs-o username=everyone,password= "" / / 192.168.1.2/bak $src

Backup () {

NewFile= `ls-At $src | head-n 1` > / tmp/ic.src # the first file in chronological order

If [- z "$newFile"]

Then

Echo "Bak Null" | mail-s "Bak Null!" 111111@sina.com

Else

\ cp-a $src$newFile $dst

File= `ls-At $dst | head-n 1` > / tmp/ic.dst

Diff / tmp/ic.src / tmp/ic.dst

If [$?-eq 0]

Then

Echo "$dateTime $File OK" > > / root/log/ic.log

Else

Echo "$dateTime $File Fail" > > / root/log/ic.log

Fi

Fi

Rm-f / tmp/ic.*

}

Backup

Umount $src

# executed at 1:00 on the 5th of every month

0 1 5 * * / sh/bak.sh 2 > > / log/ic.err

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report