
たとえば、できること
cp -R folder1 /Volume/Data
または
some_cp folder1 [email protected]/some/path/folder1
そして、15GBのファイルをコピーしてから20〜30秒間眠りますか?したがって、コマンドが15 GBをコピーするたびに、20秒、30秒、または指定された時間休止状態になり、ハードドライブがリラックスして過度のストレスを受けないことがあります。
データ量に加えて、もう1つの可能性は、3分ごとにファイルをコピーしてから1分間リラックスすることです。
答え1
シェルスクリプト
すべてがコピーされるまで繰り返されるbashシェルスクリプトを作成しました。大容量ファイルがある場合は、以前の繰り返しからコピーしたものを活用することが重要であり、コピープロセスの進行状況を「見る」ことをお勧めします。
#!/bin/bash
########################################################################
function usage {
echo "
Usage: $0 source-dir/ target-dir # copies content of source-dir
$0 source-dir target-dir # copies source-dir (with subdirs)
"
exit
}
########################################################################
# main
########################################################################
if [ $# -ne 2 ]
then
usage
fi
if ! test -d "$1"
then
echo "$1 is not a directory"
if test -f "$1"
then
echo "but $1 is a file :-)"
else
echo "and $1 is not a file :-("
usage
fi
fi
if ! test -d "${2##*:}" # allowing network directories
then
echo "$2 is not a directory :-("
usage
else
echo "$2 is a directory :-)"
fi
cont=true
while $cont
do
echo "copying ..."
timeout --foreground 25 rsync --info=progress2 --partial -Ha "$1" "$2"
if [ "$?" != "0" ]
then
cont=true
echo "flushing the buffers ..."
sync
echo "sleeping for 5 seconds ..."
sleep 5
else
cont=false
fi
done
echo "final flushing of buffers ..."
sync
echo "Dome :-)"
使用法
シェルスクリプトを実行可能にして引数なしで実行すると、次のヘルプメッセージが表示されます。
Usage: ./rsyncer-w-pause source-dir/ target-dir # copies content of source-dir
./rsyncer-w-pause source-dir target-dir # copies source-dir (with subdirs)
遅いUSBペンドライブから、Linuxディストリビューションを含む一部のisoファイルをハードドライブにコピーしてシェルスクリプトをテストしました。これにより複数の反復が実行され、isoファイルの途中でコピーが中断されますが、コピーされた部分は次の反復で使用できます。そこで大容量ファイルもコピーが可能かどうか確認してみました。
実際のコピーに使用するには、コピー時間も(25秒で)増やし、スリープ時間も(5秒で)増やす必要があるようです。特定のタスクに最適な時間間隔を使用してください。
コマンドラインオプションとパラメータに関する注意事項
timeout
このコマンドは、ファイルのコピー中に制御するコマンドの実行を停止します。
--foreground
when not running timeout directly from a shell prompt,
allow COMMAND to read from the TTY and get TTY signals; in this
mode, children of COMMAND will not be timed out
このコマンドはrsync
強力なコピーコマンドです。man rsync
可能なオプションの完全な説明についてはを参照してください。
--info=FLAGS
This option lets you have fine-grained control over the informa‐
tion output you want to see. An individual flag name may be
followed by a level number, with 0 meaning to silence that out‐
put, 1 being the default output level, and higher numbers
increasing the output of that flag (for those that support
higher levels). Use --info=help to see all the available flag
names, what they output, and what flag names are added for each
increase in the verbose level. Some examples:
rsync -a --info=progress2 src/ dest/
rsync -avv --info=stats2,misc1,flist0 src/ dest/
--partial
By default, rsync will delete any partially transferred file if
the transfer is interrupted. In some circumstances it is more
desirable to keep partially transferred files. Using the --par‐
tial option tells rsync to keep the partial file which should
make a subsequent transfer of the rest of the file much faster.
--hard-links
このオプションが気に入ったり、気に入らないことがあります。
-H, --hard-links
This tells rsync to look for hard-linked files in the source and
link together the corresponding files on the destination. With‐
out this option, hard-linked files in the source are treated as
though they were separate files.
-a, --archive
This is equivalent to -rlptgoD. It is a quick way of saying you
want recursion and want to preserve almost everything (with -H
being a notable omission). The only exception to the above
equivalence is when --files-from is specified, in which case -r
is not implied.
Note that -a does not preserve hardlinks, because finding multi‐
ply-linked files is expensive. You must separately specify -H.
最後に、パラメータ(ソースとターゲット)の説明を読み、
rsync -avz foo:src/bar /data/tmp
This would recursively transfer all files from the directory src/bar on
the machine foo into the /data/tmp/bar directory on the local machine.
The files are transferred in "archive" mode, which ensures that sym‐
bolic links, devices, attributes, permissions, ownerships, etc. are
preserved in the transfer. Additionally, compression will be used to
reduce the size of data portions of the transfer.
rsync -avz foo:src/bar/ /data/tmp
A trailing slash on the source changes this behavior to avoid creating
an additional directory level at the destination. You can think of a
trailing / on a source as meaning "copy the contents of this directory"
as opposed to "copy the directory by name", but in both cases the
attributes of the containing directory are transferred to the contain‐
ing directory on the destination. In other words, each of the follow‐
ing commands copies the files in the same way, including their setting
of the attributes of /dest/foo:
rsync -av /src/foo /dest
rsync -av /src/foo/ /dest/foo
答え2
pid
複製プロセスに関する情報を取得し、それを一時停止してから再開できます。
rsync
いつでも使用して停止することもでき、再起動すると残りのファイルのコピーが開始されます。
rsync
ただし、rsyncプロセスを使用して一時停止することをお勧めします。
rsync
pidが1234であるとします。
to pause:
kill -s STOP 1234
to continue:
kill -s CONT 1234