IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    Using rsync to backup remote n00 files

    Haidong Ji发表于 2015-01-28 04:16:50
    love 0

    I had trouble rsync remote Linux 600 files (rw——-) today. I knew that I came across this issue before but couldn’t remember how I resolved it. Therefore I had to waste time looking for and verifying a solution. Hence this blog post.

    This is the problem I had earlier:

    rsync -zr userA@remoteServer:/var/www/website/ /home/user/Documents/webSiteBackup/website/www/
    rsync: send_files failed to open "/var/www/website/wp-config.php": Permission denied (13)
    rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1655) [generator=3.1.0]
    

    So the issue is that wp-config.php is a 600 file, meaning only root can read and write it. Although userA@remoteServer has sudo privilege, I still need to run visudo so that it won’t ask for password when this user runs rsync.

    Here is the line I added into visudo:

    userA    ALL=(root) NOPASSWD: /usr/bin/rsync
    

    And here is the slightly modified bash command to run:

    rsync --rsync-path="sudo rsync" -zr userA@remoteServer:/var/www/website/ /home/user/Documents/webSiteBackup/website/www/
    

    Hope it helps you as well.



沪ICP备19023445号-2号
友情链接