release node
v1 初始版本
#定义备份目录#当前时间#检查备份目录是否存在,不存在需要创建# 查找并备份 .xxx 文件# 提取文件名(不包含路径部分)# 构建备份文件名# 将查出来的.xxx文件拷贝到备份目录
#!/bin/bash
backup_dir = "/tianhaodata/context"
echo "定义备份目录: $backup_dir "
current_date = $( date +"%Y%m%d" )
echo "当前时间: $current_date "
if [ ! -d "$backup_dir " ] ; then mkdir -p "$backup_dir " echo "创建备份目录: $backup_dir "
fi
find / -type f -name "*.txt" | while read -r xxx_file ; do file_name = $( basename "$xxx_file " ) backup_file = "$backup_dir /${file_name} _${current_date} " cp "$xxx_file " "$backup_file " echo "备份文件 $xxx_file 到 $backup_file "
done
release node
v1.1 逻辑修改
#定义备份目录# 当前时间# 判断备份目录是否存在,不存在需要创建# 如果备份目录存在,需要删除这个备份目录重新创建# 查找并备份 .xxx 文件# 提取文件名(不包含路径部分)# 构建备份文件名# 将查出来的.xxx文件拷贝到备份目录
#!/bin/bash
backup_dir = "/tianhaodata/context"
echo "定义备份目录: $backup_dir "
current_date = $( date +"%Y%m%d" )
echo "当前时间: $current_date "
if [ ! -d "$backup_dir " ] ; then mkdir -p "$backup_dir " echo "创建备份目录: $backup_dir "
fi
find / -type f -name "*.txt" | while read -r xxx_file ; do file_name = $( basename "$xxx_file " ) backup_file = "$backup_dir /${file_name} _${current_date} " cp "$xxx_file " "$backup_file " echo "备份文件 $xxx_file 到 $backup_file "
done
release node
v2.0 重新定义路径
#定义路径#定义备份目录# 当前时间# 判断备份目录是否存在,不存在需要创建# 如果备份目录存在,需要删除这个备份目录重新创建# 查找并备份 .xxx 文件# 提取文件名(不包含路径部分)# 构建备份文件名# 将查出来的.xxx文件拷贝到备份目录
#!/bin/bash
root_dir = "/"
backup_dir = "/tianhaodata/context"
echo "定义备份目录: $backup_dir "
current_date = $( date +"%Y%m%d" )
echo "当前时间: $current_date "
if [ ! -d "$backup_dir " ] ; then mkdir -p "$backup_dir " echo "创建备份目录: $backup_dir "
fi
find / -type f -name "*.txt" | while read -r xxx_file ; do file_name = $( basename "$xxx_file " ) backup_file = "$backup_dir /${file_name} _${current_date} " cp "$xxx_file " "$backup_file " echo "备份文件 $xxx_file 到 $backup_file "
done