Score:0

scp only files not already in target directory

sa flag

I'm trying to copy a large number of files from my local machine down to my server using scp. The problem I'm having is it takes a while and my internet occasionally drops. So I would like to update the script below so that it only copies the files in the source "path1" on my local machine, that aren't already on my server at "path2". Can anyone please suggest a slick way to do this?

scp -r /path1 username@servername:/path2
Score:1
ru flag

Use rsync (man rsync for syntax). Very powerful tool for syncing files between local or remote locations. Parameters to note are -n or --dry-run to see what a command will do but without doing anything.

You can do all sorts of things like compare files on based on different things like file size or datetime as well as delete files for example so that if you delete files on the source they are also deleted on the destination.

user3476463 avatar
sa flag
thank you rsync worked great. followed the syntax example from this post https://superuser.com/questions/1722338/rsync-from-macos-to-ubuntu "rsync -avzhe ssh ~/Folder [email protected]:/home/ole/"
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.