recursively use scp but excluding some folders

后端 未结 6 644
庸人自扰
庸人自扰 2021-01-30 12:25

Assume there are some folders with these structures

/bench1/1cpu/p_0/image/
/bench1/1cpu/p_0/fl_1/
/bench1/1cpu/p_0/fl_1/
/bench1/1cpu/p_0/fl_1/
/bench1/1cpu/p_0         


        
6条回答
  •  悲哀的现实
    2021-01-30 12:51

    Assuming the simplest option (installing rsync on the remote host) isn't feasible, you can use sshfs to mount the remote locally, and rsync from the mount directory. That way you can use all the options rsync offers, for example --exclude.

    Something like this should do:

    sshfs user@server: sshfsdir
    rsync --recursive --exclude=whatever sshfsdir/path/on/server /where/to/store
    

    Note that the effectiveness of rsync (only transferring changes, not everything) doesn't apply here. This is because for that to work, rsync must read every file's contents to see what has changed. However, as rsync runs only on one host, the whole file must be transferred there (by sshfs). Excluded files should not be transferred, however.

提交回复
热议问题