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

2015-02-13 0 385
自动同步硬盘和u盘上的文件
#!/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}

遇见资源网 shell 自动同步硬盘和u盘上的文件 http://www.ox520.com/16853.html

上一篇: 重启JBOSS & Tomcat
下一篇: Powershell访问MySQL
常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务