
フォルダーをリモート サーバー フォルダーに rsync し、転送全体が完了した後にのみすべてを移動する方法はありますか?
実行中の Web サーバーに問題が発生するため、ファイルを次々に移動することは望ましくありません。
すべてをサーバーに転送した後で、フォルダー全体を移動したい(これには約 1 秒かかります)
答え1
あなたが探しているのは--遅延更新オプションman rsync
。
--delay-updates This option puts the temporary file from each updated file into a holding directory until the end of the transfer, at which time all the files are renamed into place in rapid succession. This attempts to make the updating of the files a little more atomic. [...] See also the "atomic-rsync" perl script in the "support" subdir for an update algorithm that is even more atomic (it uses --link-dest and a parallel hierarchy of files).
答え2
最も安全な方法は、rsyncを使ってファイルをウェブサーバーのdocroot外の別のディレクトリに置くことです。次に、サーバーの設定を変更してdocrootを新しいフォルダに向け、ウェブサーバーに次の操作を実行するよう指示します。「優雅な」設定をリロードします。Apache では、これによりリクエストが誤って処理されたりドロップされたりすることがなくなります。
USR1 または graceful シグナルにより、親プロセスは子プロセスに現在のリクエストの後に終了するように (または何も処理していない場合はすぐに終了するように) 指示します。親プロセスは構成ファイルを再度読み取り、ログ ファイルを再度開きます。各子プロセスが終了すると、親プロセスは新しい世代の構成の子プロセスに置き換え、新しいリクエストにすぐに対応し始めます。
言い換えれば、Web サーバーを管理するための rsync オプションを探すのではなく、シェル スクリプトと ssh を使用してこれを自動化します。