Score:0

Making sure rsync only deletes files from source that also exist at the destination

gs flag

Recently, I used rsync to copy a big directory with lots of sub-directories to an external HDD. Some files had too long file names and rsync couldn't copy them. After truncating the too long file names, I want those files to be copied as well. However, once I typed in a wrong rsync command and it copied into another directory, while --remove-source-files was one of the flags and consequently, some of the source directories were removed.

Now I want to have all the files at the destination to remain intact, without having anything in the destination removed/deleted, while having the new files at the source copied and the files that are common between to source and destination removed from the source.

Would this command do exactly what I want? Dry-run doesn't show what files would be removed:

rsync -nrhtPsvv --stats --ignore-existing --remove-source-files /run/media/username/hdd1/DIR1 /run/media/username/external_hdd

As far as I know, --ignore-existing wouldn't work with --remove-source-files.

David avatar
cn flag
If you do not want them removed why the flag to force them to be removed?
Sepp A avatar
gs flag
@David I want only the source files that are common between the source and destination to be removed.
David avatar
cn flag
Unless you have resolved the too long file names nothing will do what you want.
Sepp A avatar
gs flag
@Terrance I think you just skimmed through my post.
Terrance avatar
id flag
Oops, my bad. I missed the one line. I do however think that the `-u` or `--update` command might do what you want.
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.