six*_*ude 2 backup unix script bash
我编写了这个备份脚本,它查看文件并将最近的文件复制到一个文件夹中。
#!/usr/bin/bash
# the number of days to do the backup for.
days=2;
# the files to backup.
location[0]='/opt/location'
# the location to copy the file to
copyLocation='/users/me/Backup/firstBackupScriptTry'
# preform the back up
for i in ${location[*]}
do
find $i \! -name '*.class' -mtime -$days \! -type d -exec cp {} $copyLocation \;
done
Run Code Online (Sandbox Code Playgroud)
它有效,但不是那么有用。
我希望脚本在复制时保留目录结构。即我希望它这样做:cp -r from to但只复制最近的文件。