rsync : Recursively sync all files while ignoring the directory structure

后端 未结 4 853
一生所求
一生所求 2021-02-12 18:45

I am trying to create a bash script for syncing music from my desktop to a mobile device. The desktop is the source.

Is there a way to make rsync recursively sync files

4条回答
  •  执笔经年
    2021-02-12 19:27

    If you can make a list of files, you've already solved the problem. Try:

    find /path/to/src/ -name \*.mp3 > list.txt
    rsync -avi --no-relative --progress --files-from=list.txt / user@server:/path/to/dest
    

    If you run the script again for new files, it will only copy the missing files.

    If you don't like the list, then try a single sentence (but it's another logic)

    find /path/to/src/ -name \*.mp3 -type f \
      -exec rsync -avi --progress {} user@server:/path/to/dest/  \;
    

    In this case, you will ask for each file, each time, since by the type of sentence, you cannot build the file list previously.

提交回复
热议问题