Rsync copy directory contents but not directory itself

前端 未结 4 1572
野趣味
野趣味 2021-01-30 19:29

I\'m trying to synchronize two contents of folders with different name:

rsync -av ~/foo user@remote.com:/var/www/bar

I\'d like to copy the cont

相关标签:
4条回答
  • 2021-01-30 19:39

    It's simple,

    rsync /var/www/ /home/var - copies the contents of /var/www/ but not the www folder itself.

    rsync /var/www /home/var - copies the folder www along with all its contents.

    The "/" makes the difference.

    0 讨论(0)
  • 2021-01-30 19:47

    Try rsync -av ~/foo/ user@remote.com:/var/www/bar/

    0 讨论(0)
  • 2021-01-30 19:48

    Not related only to rsync, but when you are looking for examples on how to use a GNU/Linux command, you can use "eg" which displays explicit examples. eg is available here, with instructions on how to install it: https://github.com/srsudar/eg

    The result for eg rsync is as follow

    # rsync
    
    
    copy the folder source_dir and its content into destination_dir
    
        rsync -av source_dir destination_dir
    
    
    copy the contents of source_dir (trailing slash) into destination_dir
    
        rsync -av source_dir/ destination_dir
    
    0 讨论(0)
  • 2021-01-30 19:53

    Navigate into the directory you would like to copy over, so:

    cd ~/foo 
    

    Run this:

    rsync -avz . user@remote.com:/var/www/bar
    
    0 讨论(0)
提交回复
热议问题