rsyncはファイルを移動してディレクトリを保持しますか?

rsyncはファイルを移動してディレクトリを保持しますか?

rsync内蔵ハードドライブと外付けハードドライブの間にデータをコピーするために使用します。必要な作業を行いますが、内蔵ハードドライブの容量が不足しています。それで、そのように動作させる方法はありますか?rsync空のディレクトリの「スケルトン」を元の場所に置き、ファイルを削除したら、ディレクトリに追加のファイルを配置してから再度追加してコピーできます。古いファイルを削除せずに新しいファイルを外付けドライブに保存しますか?mvcprsync

あるいは、タスクを実行できるLinuxを認識しないプログラムがある場合rsyncでも問題ありません。

ベストアンサー1

特別なオプションがありますrsync

   --remove-source-files
          This tells rsync to remove  from  the  sending  side  the  files
          (meaning  non-directories)  that  are a part of the transfer and
          have been successfully duplicated on the receiving side.

          Note that you should only use this option on source  files  that
          are quiescent.  If you are using this to move files that show up
          in a particular directory over to another host, make  sure  that
          the  finished  files  get renamed into the source directory, not
          directly written into it, so that rsync can’t possibly  transfer
          a  file that is not yet fully written.  If you can’t first write
          the files into a different directory, you should  use  a  naming
          idiom  that lets rsync avoid transferring files that are not yet
          finished (e.g. name the  file  "foo.new"  when  it  is  written,
          rename  it  to  "foo"  when  it is done, and then use the option
          --exclude='*.new' for the rsync transfer).

          Starting with 3.1.0, rsync will  skip  the  sender-side  removal
          (and  output an error) if the file’s size or modify time has not
          stayed unchanged.

ターゲットファイルの削除は選択内容によって異なります。ただし、公平に言えば、などのオプション--deleteを使用しないと--delete-before何も削除されません。

おすすめ記事