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