Linux自动备份文件
根据日期创建目录
并根据执行次数自动创建子目录
若有异常并提示错误行号
#!/bin/bash sourcedir=/ backupdir=/var/backup/`date +%Y%m%d` logfile=/usr/bi/import/log_`date +%Y%m%d`.log today=`date '+%Y-%m-%d %H:%M:%S'` trap 'echo line:¥LINENO failed >>$logfile' ERR echo "$today : backup start" >> $logfile if [ -d $backupdir ]; then echo "$today : $backupdir is already exsist" >> $logfile else mkdir -p $backupdir fi echo "$today : backup parent dir $backupdir ." >> $logfile cd $backupdir for i in `seq 1 100`; do if [ -d $i ]; then echo "$today : $i is already exsist" >> $logfile else mkdir $backupdir/$i newbackup=$backupdir'/'$i break fi done echo "$today : backup dir $newbackup ." >> $logfile cp -R /home/ftp/ftptest/* $newbackup echo "$today : backup end" >> $logfile echo -e "\n" >>$logfile exit 0
相关推荐
laisean 2020-11-11
Julyth 2020-10-16
laisean 2020-09-27
flycappuccino 2020-09-27
liguojia 2020-09-27
87201442 2020-10-15
MXstudying 2020-09-05
WasteLand 2020-09-15
<?php. if (!empty($_POST)) {. $data1 = $_POST["data1"];$data2 = $_POST["data2"];$fuhao = $_POST["fuh
mathchao 2020-09-15
tvk 2020-07-30
Zaratustra 2020-07-29
zhaowj00 2020-07-26
Zaratustra 2020-06-26
ldcwang 2020-06-25
拿什么来拯救自己 2020-06-21
IsanaYashiro 2020-06-16
赵家小少爷 2020-06-14
大牛牛 2020-06-14