How to RSYNC a single file?

后端 未结 4 1452
庸人自扰
庸人自扰 2021-01-31 06:33

Currently i only RSync-ing the Directories as like:

* * * * * rsync -avz /var/www/public_html/images root@:/var/www/public_html
         


        
4条回答
  •  逝去的感伤
    2021-01-31 07:14

    Michael Place's answer works great if, relative to the root directory for both the source and target, all of the directories in the file's path already exist.

    But what if you want to sync a file with this source path:

    /source-root/a/b/file

    to a file with the following target path:

    /target-root/a/b/file

    and the directories a and b don't exist?

    You need to run an rsync command like the following:

    rsync -r --include="/a/" --include="/a/b/" --include="/a/b/file" --exclude="*" [source] [target]
    

提交回复
热议问题