我在一台古老的 Dell Dimension 4550 台式机上运行 Ubuntu Server 18.04,我用这台台式机备份了 13 个安全摄像头。每天通过 cron 和 rsync 执行 4 次备份。通常,当 cronscript 到达第 13 个摄像头时,复制速度就会慢得像爬行一样,有时需要 1 到 2 分钟才能复制每个 650KB 的图像文件。为了加快速度,我在 rsync cronscript 中添加了 -W 和 --ignore-existing 开关,因为这些对我来说并不是非常重要,但速度提升只是微不足道的。我甚至添加了一个“killall rsync”脚本,该脚本在每个 cronscript 执行 2 个半小时后执行,因为有时当下一个计划时间到达时(3 小时),前一个 cronscript 仍在运行 rsync。如果有帮助的话,这是备份 cronscript:
#!/bin/sh
LOGFILE=/data/cameras/"$(date "+%Y-%m")_Archive.log"
PWORD=************
echo "----- Starting Camera Archive @ $(date "+%m-%d-%Y %T") -----" >> $LOGFILE 2>&1
#####
[email protected]
CAMNAME=FrontRight
echo "$(date "+%m-%d-%Y %T") : Starting "$CAMNAME" script" >> $LOGFILE 2>&1
sshpass -p $PWORD rsync -rW --ignore-existing $CAMIP:/data/output/$CAMNAME /data/cameras
rm -rf /data/cameras/$CAMNAME/.keep
echo "$(date "+%m-%d-%Y %T") : Ending "$CAMNAME" script" >> $LOGFILE 2>&1
#####
[email protected]
CAMNAME=FrontLeft
echo "$(date "+%m-%d-%Y %T") : Starting "$CAMNAME" script" >> $LOGFILE 2>&1
sshpass -p $PWORD rsync -rW --ignore-existing $CAMIP:/data/output/$CAMNAME /data/cameras
rm -rf /data/cameras/$CAMNAME/.keep
echo "$(date "+%m-%d-%Y %T") : Ending "$CAMNAME" script" >> $LOGFILE 2>&1
#####
[email protected]
CAMNAME=Driveway
echo "$(date "+%m-%d-%Y %T") : Starting "$CAMNAME" script" >> $LOGFILE 2>&1
sshpass -p $PWORD rsync -rW --ignore-existing $CAMIP:/data/output/$CAMNAME /data/cameras
rm -rf /data/cameras/$CAMNAME/.keep
echo "$(date "+%m-%d-%Y %T") : Ending "$CAMNAME" script" >> $LOGFILE 2>&1
#####
[email protected]
CAMNAME=Garage
echo "$(date "+%m-%d-%Y %T") : Starting "$CAMNAME" script" >> $LOGFILE 2>&1
sshpass -p $PWORD rsync -rW --ignore-existing $CAMIP:/data/output/$CAMNAME /data/cameras
rm -rf /data/cameras/$CAMNAME/.keep
echo "$(date "+%m-%d-%Y %T") : Ending "$CAMNAME" script" >> $LOGFILE 2>&1
#####
[email protected]
CAMNAME=SideYard
echo "$(date "+%m-%d-%Y %T") : Starting "$CAMNAME" script" >> $LOGFILE 2>&1
sshpass -p $PWORD rsync -rW --ignore-existing $CAMIP:/data/output/$CAMNAME /data/cameras
rm -rf /data/cameras/$CAMNAME/.keep
echo "$(date "+%m-%d-%Y %T") : Ending "$CAMNAME" script" >> $LOGFILE 2>&1
#####
[email protected]
CAMNAME=Basement
echo "$(date "+%m-%d-%Y %T") : Starting "$CAMNAME" script" >> $LOGFILE 2>&1
sshpass -p $PWORD rsync -rW --ignore-existing $CAMIP:/data/output/$CAMNAME /data/cameras
rm -rf /data/cameras/$CAMNAME/.keep
echo "$(date "+%m-%d-%Y %T") : Ending "$CAMNAME" script" >> $LOGFILE 2>&1
#####
[email protected]
CAMNAME=Sunroom
echo "$(date "+%m-%d-%Y %T") : Starting "$CAMNAME" script" >> $LOGFILE 2>&1
sshpass -p $PWORD rsync -rW --ignore-existing $CAMIP:/data/output/$CAMNAME /data/cameras
rm -rf /data/cameras/$CAMNAME/.keep
echo "$(date "+%m-%d-%Y %T") : Ending "$CAMNAME" script" >> $LOGFILE 2>&1
#####
[email protected]
CAMNAME=BackLeft
echo "$(date "+%m-%d-%Y %T") : Starting "$CAMNAME" script" >> $LOGFILE 2>&1
sshpass -p $PWORD rsync -rW --ignore-existing $CAMIP:/data/output/$CAMNAME /data/cameras
rm -rf /data/cameras/$CAMNAME/.keep
echo "$(date "+%m-%d-%Y %T") : Ending "$CAMNAME" script" >> $LOGFILE 2>&1
#####
[email protected]
CAMNAME=BackRight
echo "$(date "+%m-%d-%Y %T") : Starting "$CAMNAME" script" >> $LOGFILE 2>&1
sshpass -p $PWORD rsync -rW --ignore-existing $CAMIP:/data/output/$CAMNAME /data/cameras
rm -rf /data/cameras/$CAMNAME/.keep
echo "$(date "+%m-%d-%Y %T") : Ending "$CAMNAME" script" >> $LOGFILE 2>&1
#####
[email protected]
CAMNAME=Utilities
echo "$(date "+%m-%d-%Y %T") : Starting "$CAMNAME" script" >> $LOGFILE 2>&1
sshpass -p $PWORD rsync -rW --ignore-existing $CAMIP:/data/output/$CAMNAME /data/cameras
rm -rf /data/cameras/$CAMNAME/.keep
echo "$(date "+%m-%d-%Y %T") : Ending "$CAMNAME" script" >> $LOGFILE 2>&1
#####
[email protected]
CAMNAME=Bedroom
echo "$(date "+%m-%d-%Y %T") : Starting "$CAMNAME" script" >> $LOGFILE 2>&1
sshpass -p $PWORD rsync -rW --ignore-existing $CAMIP:/data/output/$CAMNAME /data/cameras
rm -rf /data/cameras/$CAMNAME/.keep
echo "$(date "+%m-%d-%Y %T") : Ending "$CAMNAME" script" >> $LOGFILE 2>&1
#####
[email protected]
CAMNAME=Extra
echo "$(date "+%m-%d-%Y %T") : Starting "$CAMNAME" script" >> $LOGFILE 2>&1
sshpass -p $PWORD rsync -rW --ignore-existing $CAMIP:/data/output/$CAMNAME /data/cameras
rm -rf /data/cameras/$CAMNAME/.keep
echo "$(date "+%m-%d-%Y %T") : Ending "$CAMNAME" script" >> $LOGFILE 2>&1
#####
[email protected]
CAMNAME=Motorhome
echo "$(date "+%m-%d-%Y %T") : Starting "$CAMNAME" script" >> $LOGFILE 2>&1
sshpass -p $PWORD rsync -rW --ignore-existing $CAMIP:/data/output/$CAMNAME /data/cameras
rm -rf /data/cameras/$CAMNAME/.keep
echo "$(date "+%m-%d-%Y %T") : Ending "$CAMNAME" script" >> $LOGFILE 2>&1
#####
echo "====== Ending Camera Archive @ $(date "+%m-%d-%Y %T") ======" >> $LOGFILE 2>&1
echo " " >> $LOGFILE 2>&1
#####