Shell programming, backing up files across servers

Source: Internet
Author: User

Requirements: Query all files under a folder, change the file modification time to less than the current time, and be larger than the current time the previous day of the file backup to another server corresponding to the folder

Ideas:

1, recursive query folder under the file

2. If the folder contains spaces, the files are displayed as columns and IFS is set to \x0a

The code is as follows:

#!/bin/bashfunction Read_dir () {IFS=$'\x0a'executedate= ' date-d'-1 Day'+%F" "%T' ExecuteDate1= ' date-d"${executedate}"+%s`     forFile in ' LS $1|Paste ' Domodifydate=`Stat$1"/"$file-C%y' currentdate= ' Date +%F" "%T' CurrentDate1= ' date-d"${currentdate}"+%s' ModifyDate1= ' date-d"${modifydate}"+%s`        if[-D $1"/"$file] then Read_dir $1"/"$fileElif [$modifyDate 1-lt$currentDate 1] && [$modifyDate 1-gt$executeDate 1 ]; Then SCP-R" $""/" "$ip:"$pathfi Done}path=/root/Huip[Email protected]192.168.11.66Read_dir$path $ip

Shell programming, backing up files across servers

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.