rsync运行多个进程

时间:2014-06-04 10:57:23

标签: linux bash cron rsync

我有2个使用rsync运行的备份脚本。第一个只有一组过程可见

另一个最终会有50多个进程。请参见下面的屏幕截图。

这两个作业都是通过cron运行的,都有一个锁文件设置。

这是脚本:

#!/bin/bash
PATH=/usr/lib64/qt-    3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin


LinkDest=/home/backup/files/backupdaily/monday

WeekDay=$(date +%A |tr [A-Z] [a-z])
LogDay=$(date +%F)
lockfile=/var/tmp/backup_daily_v3-lockfile

if ( set -o noclobber; echo "$$" > "$lockfile") 2> /dev/null; then

        trap 'rm -f "$lockfile"; exit $?' INT TERM EXIT

        # do stuff here

echo "$WeekDay"

case $WeekDay in

    monday) 
  echo "Starting monday's backup"
    rsync -avz --delete --exclude backup --exclude virtual_machines /home   /home/backup/files/backupdaily/monday --log-  file=/usr/local/src/backup/logs/backup_daily_M_$LogDay.log
        ;;

    tuesday|wednesday|thursday|friday|saturday)
    echo "Starting inc backup : $WeekDay"   
    rsync -avz --exclude backup --exclude virtual_machines --link-dest=$LinkDest /home   /home/backup/files/backupdaily/$WeekDay --log- file=/usr/local/src/backup/logs/backup_daily_$LogDay.log
        ;;

    sunday)    exit 0
        ;;
esac

        # clean up after yourself, and release your trap
        rm -f "$lockfile"
        trap - INT TERM EXIT
else
        echo "Lock Exists: $lockfile owned by $(cat $lockfile)"
fi

这里是屏幕截图enter image description here

0 个答案:

没有答案