Commits

Xenith Orb committed 37467c5

Changed a few things arround, added gzip.

Comments (0)

Files changed (1)

 TARGET_VGNAME="backup" # The volume group name at the remote machine
 LVSIZE="500M" 	       # The size you want for LVM snapshot storage
 SUFFIX="snap1"         # Suffix to append to snapshots for identification
-BYTE_SIZE="16M"	       # Byte size to use with dd 
+BYTE_SIZE="2M"	       # Byte size to use with dd 
 PORT="9000"	       # Port to use with netcat
 REMOTE_HOST="vm-local" # DNS or IP addr of remote machines
 ############################################################################
 	done
 }
 create_snaps () {
+	sync
 	for lvname in ${vol_name[@]}; do 
 		lvcreate --size ${LVSIZE} --snapshot \
 		--name ${lvname}-${SUFFIX} /dev/${SOURCE_VGNAME}/${lvname} 
 		lvremove -f /dev/${SOURCE_VGNAME}/${lvname}-${SUFFIX}
 	done
 }
+delete_remote_lvolumes () {
+	#vgscan ## just in case : not needed for remote w/ ssh
+	for lvname in ${vol_name[@]}; do 
+		ssh root@${REMOTE_HOST} "lvremove -f /dev/${TARGET_VGNAME}/${lvname}"
+	done 
+}
 create_remote_lvolumes () {
 	#vgscan ## just in case : not needed for remote w/ ssh
 	local count=0
 	for lvname in ${vol_name[@]}; do
 		echo -e "Starting clone of: ${lvname}-${SUFFIX}" 
 		# Disable the below line to not run w/ SSH
-		ssh root@${REMOTE_HOST} "nc -l -p ${PORT} | bzip2 -d | dd bs=${BYTE_SIZE} of=/dev/${TARGET_VGNAME}/${lvname}" &&
-		dd bs=${BYTE_SIZE} if="/dev/${SOURCE_VGNAME}/${lvname}-${SUFFIX}" | bzip2 -c | nc ${REMOTE_HOST} ${PORT} 
+		ssh root@${REMOTE_HOST} "nc -l -p ${PORT} | gzip -cd | dd bs=${BYTE_SIZE} of=/dev/${TARGET_VGNAME}/${lvname}"
+		dd bs=${BYTE_SIZE} if="/dev/${SOURCE_VGNAME}/${lvname}-${SUFFIX}" | gzip -c | nc ${REMOTE_HOST} ${PORT} 
 	done
 }
 ########### Older function for using with a presetup NBD device 
 	echo -ne "\nUsage:\t ${SCRIPTNAME}  -r, create-remote\t	Create remote volumes.\n"
 	echo -ne "	 ${SCRIPTNAME}  -c, create-snaps\t	Create local snapshots.\n"
 	echo -ne "	 ${SCRIPTNAME}  -d, delete-snaps\t	Delete local snapshots.\n"
+	echo -ne "	 ${SCRIPTNAME}  --remove-remote-vols	Delete remote volumes.\n"
 	echo -ne "	 ${SCRIPTNAME}  -s, clone, --clone	Clone volumes remotely.\n"
 	echo -ne "	 ${SCRIPTNAME}  -v, view	\t	Print volumes applicable.\n\n"
 	echo -ne "	 Options must be given individually\n\n"
 	    get_names_and_sizes
 	    create_remote_lvolumes
 	;;
+	--remove-remote-vols)
+	    get_names_and_sizes
+	    delete_remote_lvolumes
+	;;
 	delete-snaps|-d)
 	    get_names_and_sizes
 	    delete_snaps