LoginSignup
0
0

More than 3 years have passed since last update.

複数ファイルを1回でrsyncする

Last updated at Posted at 2021-01-15

--files-fromオプション

  • rsyncしたいファイル名を改行区切りでテキストファイルに記載
  • そのテキストファイルを指定して、1回のrsyncコマンドで送信する
  • rsyncしたいファイルは同一のディレクトリに格納されている必要がある。

準備

/path/to/images.txtにファイル名を入力(改行で区切る)

images.txt
file1.png
file2.png
file3.png

実装

※送信元のディレクトリにimages.txtに記入したファイルがあることを確認

$images = '/path/to/images.txt'
$src_path = '/path/to/src/';
$tar_path = '/path/to/tar/';
$rsync_host = 'ユーザ名@送信先IPアドレス';

$command = "rsync -av --files-from=".$images." ".$src_path." ".$rsync_host.":".$tar_path;
exec ( $command, $output, $ret );
if($ret == 0) {
   return true;
} else {
   return false;
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0