>[оверквотинг удален]
>>можно конечно писать файлик типа:
>>dd if=/src/dir1/file1.dbf of=/src/dir1/file1.dbf bs=50M
>>
>>Но для тысяч файлов это не практично и ошибиться можно, почему именно
>>dd, потому что отключено кеширование на дисках.
>>
>>Вопрос: куда копать и как быть? Кто может сталкивался?
>
>Все народ решил я проблему с dd ураа, если хотите могу выложить
>:) Вот скриптец, народ тока сильно не пинайте приму любые пожелания :)
ddcopy.sh
#!/bin/bash
#
# The given script has been created for simplification of process of
# recursive copying of files and directories by means of utility
# Dataset definition dd.
#
# The author Dmitriy V. Mazitov 2009
# v. 1
#
# Usage order the following:
#
# ddcopy.sh /source_dir /destination_dir bs cf cdd rm
#
# Explanations:
#
# bs - a block size in mbytes (the Example: we enter number 50)
#
# cf - generation of a file of a script (the Example: we enter y or n)
#
# cdd - the consent to copying (the Example: we enter y or n)
#
# rm - removal of folders and files in a destination directory
# (the Example: we enter y or n)
#
# Example:
#
# ddcopy.sh /home/bob/films /home/share/video 50 y y n
#
# The file a script will be is in a home folder of the user from which
# name has been started ddcopy.sh
#
# It is possible to create a file a script for its studying and hand-held
# performance.
#
# G U A R A N T E E S
#
# A N Y
#
# dmitriy@ituniservice.ru
#
#
clear
cd
rm -f -v start_dd_copy.sh
#=======================================
src=$1
dest=$2
block_size=$3
create_files=$4
copy_dd=$5
rm_files_and_dir=$6
l=`find $src -type f | wc -l`
let "l-=1"
LIMIT=$l
files () {
find $src -follow -type f | cat | while read line; do echo "${line##*/}"; done
}
rm_files_dest () {
find $dest -follow -type f | cat | while read line; do echo "${line##*/}"; rm "${line[@]}"; done
}
input_source () {
find $src -follow -type f | while read string
do
echo $string
done
}
search () {
LIMIT_S=(`input_source | wc -l`)
v0=(`input_source`)
for ((a=0; a <= LIMIT_S ; a++))
do
echo "${v0[a]/#$src/$dest}"
done
}
dd_out_screen () {
IF=(`input_source`)
OF=(`search`)
BLS=$block_size
for ((a=0, b=0; a <= LIMIT, b <= LIMIT ; a++, b++))
do
echo dd if="${IF[a]}" of="${OF}" bs="${BLS[@]}"M
done
}
dd_dir_for_copy() {
IF=(`input_source`)
OF=(`search`)
BLS=$block_size
for ((a=0; a <= LIMIT ; a++))
do
dirname "${OF[a]}"
done
}
create_dir () {
DIR=(`dd_dir_for_copy`)
LIMIT_S=(`input_source | wc -l`)
for ((a=0; a <= LIMIT_S ; a++))
do
mkdir -p "${DIR[a]}"
done
}
dd_copy () {
IF=(`input_source`)
OF=(`search`)
BLS=$block_size
l1=`input_source | wc -l`
let "l1-=1"
LIMIT_S=$l1
#LIMIT_S=(`input_source | wc -l`)
for ((a=0, b=0; a <= LIMIT_S, b <= LIMIT_S ; a++, b++))
do
dd if="${IF[a]}" of="${OF}" bs="${BLS[@]}"M
done
}
check_all () {
if [ "$src" = '' -o "$dest" = '' -o "$block_size" = '' -o "$create_files" = '' -o "$copy_dd" = '' -o "$rm_files_and_dir" = '' ];
then
echo "Error!"
echo "Usage: script src_dir dest_dir" >&2
echo "Example: Enter the directory a source and destination:" >&2
echo "/foo/dir1 /home/user/catalog1 10 y y y" >&2
echo "Enter 'ddcopy.sh ls --help or -h' for reception of more detailed description." >&2
exit 1
fi
}
helps () {
clear
echo "The given script has been created for simplification of process of" >&2
echo "recursive copying of files and directories by means of utility" >&2
echo "Dataset definition "dd"." >&2
echo
echo "The author Dmitriy V. Mazitov 2009" >&2
echo "v. 1" >&2
echo
echo "Usage order the following:" >&2
echo
echo "ddcopy.sh /source_dir /destination_dir bs cf cdd rm" >&2
echo
echo "Explanations:" >&2
echo
echo "bs - a block size in mbytes (the Example: we enter number 50)" >&2
echo
echo "cf - generation of a file of a script (the Example: we enter y or n)" >&2
echo
echo "cdd - the consent to copying (the Example: we enter y or n)" >&2
echo
echo "rm - removal of folders and files in a destination directory" >&2
echo "(the Example: we enter y or n)" >&2
echo
echo "Example:" >&2
echo
echo "ddcopy.sh /home/bob/films /home/share/video 50 y y n" >&2
echo
echo "The file a script will be is in a home folder of the user from which " >&2
echo "name has been started ddcopy.sh" >&2
echo
echo "It is possible to create a file a script for its studying and hand-held" >&2
echo "performance." >&2
echo
echo "G U A R A N T E E S" >&2
echo
echo "A N Y" >&2
echo
echo "dmitriy@ituniservice.ru" >&2
}
helps_check () {
if [ "$src" = '--help' -o "$src" = '-h' ]
then
echo
helps
else
echo
check_all
#exit 0
fi
}
validation_check () {
echo $src | grep '/*/' > /dev/null
if [ $? -ne 0 ]; then echo "The sources dir is incorrectly entered!"
helps_check
exit;
fi
echo $dest | grep '/*/' > /dev/null
if [ $? -ne 0 ]; then
echo "The destination dir is incorrectly entered!"
sleep 3
helps
exit;
fi
if (("$block_size" >= 1))
then
echo
else
echo "The block size is incorrectly entered!"
sleep 3
helps
exit 0
fi
if [ "$create_files" = "y" -o "$create_files" = "n" ]
then
echo
else
echo "The create command files is incorrectly entered!"
sleep 3
helps
exit 0
fi
if [ "$copy_dd" = 'y' -o "$copy_dd" = 'n' ]
then
echo
else
echo "The copy on dd command is incorrectly entered!"
sleep 3
helps
exit 0
fi
if [ "$rm_files_and_dir" = 'y' -o "$rm_files_and_dir" = 'n' ]
then
echo
else
echo "The remove files and dirs command is incorrectly entered!"
sleep 3
helps
exit 0
fi
}
run () {
if [ "$create_files" = "y" ]
then
echo
cd
dd_out_screen >> start_dd_copy.sh
chmod 777 start_dd_copy.sh
echo
else
echo
fi
if [ "$rm_files_and_dir" = 'y' ]
then
echo
rm_files_dest
else
echo
fi
if [ "$copy_dd" = 'y' ]
then
echo
create_dir
dd_copy
RETCODE=$?
if [ $RETCODE -ne 0 ]; then
echo "Err code="$RETCODE""
else
echo "Good code="$RETCODE""
fi
else
echo
fi
}
if [ "$src" = '' ]
then
echo
helps_check
else
echo
validation_check
helps_check
fi
run