Lunix/mac copy files and folders under the last modified time, keeping the original directory structure

Source: Internet
Author: User
Tags lunix

Degree Niang know: http://zhidao.baidu.com/link?url= Dd47jm6qdgt7yxsnz9e-nc4fqd33oroiiwcglkw5tl4cbf50vky2ionbhkh0ie8woewsb3p4bhbf2-u3oe4tta

Execute the shell script (which can be seen as a function bar):

1#!/bin/SH2  3 Show_usage () {4     Echo "Usage:backup_f.sh src_folder bak_folder bak_date"5     Echo "**********************************************"6     Echo "Src_folder-source folder to backup"7     Echo "Bak_folder-backup Folder"8     Echo "bak_date-backup date in YYYYMMDD format"9     Echo "bak_filename-like This:ROOT.tar"Ten     Echo "**********************************************" One } A   -   - if[$#-ne4]; Then the Show_usage -Exit1 - fi -   +Src_folder=" $" -Bak_folder=" $" +Bak_date=" $" ABak_filename="$4" at   -bak_file="$bak _folder/$bak _filename"# fixed the backup file name to Backup.tar, you can make some changes as needed - if[-F $bak _file]; Then -     RM$bak _file - fi -#Echo$bak _file in#exit1 -   totmpfile="' Mktemp '" + Touch-T ${bak_date}0000$tmpfile - CD $SRC _folder the Find. ! -name"Persistence.xml"! -path"./web-inf/logs*"! -path"./statics/*"! -path"./scripts/lib/*"-newer $tmpfile-execTarrvf $bak _file {} \; * RM$tmpfile $ Panax Notoginseng if[-F $bak _file]; Then - Echo "backup file: $bak _file" the fi +#ls-L $bak _folder

Call the Shel script:

1#!/bin/SH 2Src_folder="/code/git/worksystem/src/main/webapp"3Bak_folder="/users/cnblogs/documents/b2bweb"4Last_modify_date="20151028"5Bak_filename="Root.tar"6  7 SHBackup_f.SH$SRC _folder $bak _folder $last _modify_date $bak _filename

The original also used find command, have been used, but suddenly in the upgrade to OS X El Capitan after suddenly use, error: unknown primary or operator.

I check the information, have not found a solution, and then find the beginning of Baidu know the answer, a little change, can use.

Lunix/mac copy files and folders under the last modified time, keeping the original directory structure

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.