find+rsyncで特定期間のファイルだけ同期する

小ネタですが.
~mk/POD以下から内容更新日時が1440分(1日)以内のファイルを探して同期しています.

cd ~mk/POD ; find . -mmin -1440 -type f -print0 | rsync --delete --progress --files-from=- --from0 ~mk/POD/ /var/www/owncloud/data/matoken/files/podcast/

findコマンドで欲しいファイルを探し,rsyncでその結果を同期しています.
–files-fromに-をつけることでfindで検索したファイルを標準入力から受け取っています.
便利 :)

一応オプションの詳細

  • find
    -mmin -1440 : 内容更新日時が1440分(1日)以内
    -type f : ファイルを検索
    -print0 : 区切り文字をNULLにする

  • rsync
    –delete–delete : 無くなったファイルは削除する
    –progress : プログレスを表示
    –files-from=- : STDINから同期元ファイルリストを読み込む
    –from0 : 区切り文字をNULLとして扱う

コメントを残す

メールアドレスが公開されることはありません。 ※ が付いている欄は必須項目です

Your post must include a link to this post.

How does this work?
Write a response on your own website and include a link to this post. Then submit your response’s URL here. Your response may appear here after moderation. To update or remove it, edit or delete your original post and submit the same URL again. Learn more about Webmentions.