linux 数据备份
2016-07-07 20:20
483 查看
#!/bin/bash DATE=$(date '+%m%d%y') FILE=archive$DATE.tar.gz CONFIG_FILE=/home/user/archive/Files_To_Backup //注解 Files_To_Backup 该文件里存放需要备份的目录,文件 DESTINATION=/home/user/archive/$File #Check Backup Config file exists if [ -f $CONFIG_FILE ] then echo else echo echo "$CONFIG_FILE dose not exist." echo "Backup not completed due to missing Configuration File" echo exit fi #Bulid the names of all the files to backup FILE_NO=1 exec < $CONFIG_FILE read FILE_NAME while [ $? -eq 0 ] do if [ -f $FILE_NAME -o -d $FILE_NAME ] then #if the file exists,add its name to the list. FILE_LIST="$FILE_LIST $FILE_NAME" else # if the file doesn't exist,issue waring echo echo "$FILE_NAME ,dose not exist." echo "Obviously,I will not include it in this archive." echo “It is listed on the line $FILE_NO of the config file” echo "Continuing to build archive list...." echo fi FILE_NO=$[$FILE_NO+1] read FILE_NAME done #Backup the files and compress Archive tar -czf $DESTINATION $FILE_LIST 2>/dev/null
在 /home/user/archive 会存在备份好的压缩文件,
相关文章推荐
- linux下忘记mysql密码的找回方法--谷营中西
- Bootable partition could not be on a logical volume
- windows与linux换行符
- linux 下安装开发组件包
- 在Linux下面实现QDbus通信机制服务对象注册失败
- linux 20个有趣命令
- Linux 常用文件处理命令
- win7基于maven和eclipse连接远程Linux服务器的hadoop2.0集群的入门程序
- linux用户权限
- Linux中find常见用法示例
- linux查看内核版本、系统版本、系统位数(32or64)
- 利用securecrt在linux与windows之间传输文件
- 基于tiny4412的Linux内核移植 -- 设备树的展开
- 在Linux下使用gradle自动打包
- Linux中gcc编译过程分解
- Linux目录结构和常用命令
- Linux一键部署Web环境
- linux进程间通信-信号通信
- Linux入门:常用命令:scp上传下载文件
- CentOS安装NTFS-3g