Search code examples
filesshrsyncdelete-file

rsync over ssh delete existing files


I am trying to get files from a Server on my Raspberry Pi with rsync over ssh. Right now i'm using this (it works):

rsync -avz -e ssh USER@SERVER:'/server/directory' '/traget/directory'

Files that are not on the server anymore should now be deleted on the RP. How do I do that? (--delete seems not to work)


Solution

  • You need one more option, presuming that you have permissions to delete files under /traget/directory:

         --delete                delete extraneous files from destination dirs
    

    Also watch out for typos when executing commands that can delete files and directories!