LoginSignup
7
8

More than 5 years have passed since last update.

所有者を変更しつつ rsync する

Posted at

大抵の場合は

rsync -avz user1@remote:/path/to/dir/ dir/

のようにしてざっくりコピーすることが多いんだけど、Web用ディレクトリなんかをもう少し真面目にコピーする。

rsync -avzn --exclude='wp-config.php' \
  --exclude='.htaccess' \
  --usermap=apache:www-data,user1:example.com \
  --groupmap=apache:www-data,user1:psacln \
  --rsh="ssh -p 2222" user1@old.example.com:~user1/htdocs/ \
  ~example.com/httpdocs/

CentOSのApacheからDebianのNginxへWordPressを丸ごとコピーする想定。apacheユーザーをwww-dataにマップして、FTPユーザーをバーチャルドメインユーザーにマップする。
nオプションは DRY RUN。重要。
この後に出力を見てnを外して実行する。
一度目はexclude無しで実行して、二度目以降は手動編集したファイルを上書きしないようにexcludeを付ける。

7
8
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
7
8