自动同步硬盘和u盘上的文件

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#!/bin/bash
#rsync the hard disk files to usb disks
#usage: HDF2UDrsync  USBDISKNAME
#example: HDF2UDrsync sdb1
#the usb disk mount point is ${upath}
#usb device
if [ $# -ne 1 ]
then
	echo Usage: $(basename $0) USBDISKNAME
	echo example: $(basename $0) sdb1
	exit
fi
udevice="/dev/$1"
#usb disk mount point
upath=$(mktemp -d -t usbdisk229XXXXXX)'/'
hpath='/media/sda2/'
#source files
sf=("${hpath}lsoftware/" "${hpath}software/" "${hpath}document/" "${hpath}ghost/iso/slconfig/" "/home/000/Documents/fp/")
#destination files
df=("${upath}lsoftware/" "${upath}software/" "${upath}docs/" "${upath}iso/slconfig/" "${upath}fp/")
#mount ${udevice} on ${upath}
if [ ! -b ${udevice} ]
then
	echo "${udevice} : No such device, exit!"
	exit
fi
sudo umount ${udevice} 2> /dev/null
sudo mount ${udevice} ${upath}
clear
#rsync the files
#full rsync
for i in {0,1,2,3,4}
#partial rsync
#for i in {3,4}
do
	echo ${sf[i]} '======>>>>>>'  ${df[i]}
	#--exclude='*.bak'
	rsync\
		--specials --partial --delete --links\
		--recursive --times --update --verbose\
		--progress --human-readable\
		--exclude ".0/"\
		--exclude "vimPUNDO/"\
		--exclude "*.iso"\
		--exclude "*.mkv"\
		${sf[i]} ${df[i]}
done
#umount ${udevice}
sudo umount ${udevice}
rm -rf ${upath}

#===========================================================================

#!/bin/bash
#rsync the hard disk files to usb disks
#usage: UDF2HDrsync  USBDISKNAME
#example: UDF2HDrsync sdb1
#the usb disk mount point is ${upath}
#usb device
if [ $# -ne 1 ]
then
	echo Usage: $(basename $0) USBDISKNAME
	echo example: $(basename $0) sdb1
	exit
fi
udevice="/dev/$1"
#usb disk mount point
upath=$(mktemp -d -t usbdisk229XXXXXX)'/'
hpath='/media/sda2/'
#source files
sf=("${upath}lsoftware/" "${upath}software/" "${upath}docs/" "${upath}iso/slconfig/" "${upath}fp/")
#destination files
df=("${hpath}lsoftware/" "${hpath}software/" "${hpath}document/" "${hpath}ghost/iso/slconfig/" "/home/000/Documents/fp/")
#mount ${udevice} on ${upath}
if [ ! -b ${udevice} ]
then
	echo "${udevice} : No such device, exit!"
	exit
fi
sudo umount ${udevice} 2> /dev/null
sudo mount ${udevice} ${upath}
clear
#rsync the files
#full rsync
for i in {0,1,2,3,4}
#partial rsync
#for i in {3,4}
do
	echo ${sf[i]} '======>>>>>>'  ${df[i]}
	#--exclude='*.bak'
	rsync\
		--specials --partial --delete --links\
		--recursive --times --update --verbose\
		--progress --human-readable\
		--exclude ".0/"\
		--exclude "vimPUNDO/"\
		--exclude "*.iso"\
		--exclude "*.mkv"\
		${sf[i]} ${df[i]}
done
#umount ${udevice}
sudo umount ${udevice}
rm -rf ${upath}