Search code examples
rsync

rsync folder from local system to server does not work


I'm trying to copy my webfolder 'depot' from my local machine to my server on Digital Ocean.

For that I run this command in the terminal:

rsync -anv ./Sites/depot root@my-server-ip:/sites

But when I ssh into my server and cd into the sites folder, the 'depot' folder is not there.

Am I doing something wrong?


Solution

  • You have set the -n flag, which results in a "dry run" (you get to see which files would be copied/deleted without actually doing any damage).

    To do the actual copy you need to omit the -n flag:

    rsync -av ./Sites/depot root@my-server-ip:/sites/depot
    

    Also be careful about how you specify paths for rsync - normally you need a trailing /:

    rsync -av ./Sites/depot/ root@my-server-ip:/sites/depot/
    

    otherwise you can end up with copies of directories inside of directories (e.g. sites/depot/depot).

    See man rsync for full details.