Results 1 to 8 of 8
I use the command
cp -u ...
to copy from one place to another (e.g. to a backup device), but only
files that are new to the target directory. For ...
- 12-19-2010 #1Just Joined!
- Join Date
- Dec 2010
- Posts
- 21
cp -r -u ?
I use the command
cp -u ...
to copy from one place to another (e.g. to a backup device), but only
files that are new to the target directory. For large directories with large
files, this avoids long transfers. However, when I copy not only files but
directories with files, as in
cp -r -u ...
this seems not to work; it then takes the time it takes to copy everything,
new and old. Does the -r override the -u, and if so, why?
- 12-19-2010 #2
Seems that it does, you'd have to read the source code to see why.
Consider using rsync instead. It using a "sliding window checksum" algorithm, and not only transfers only the files that have changed, it transfers only the changed blocks of those.
- 12-20-2010 #3Just Joined!
- Join Date
- Dec 2010
- Posts
- 21
Thanks! I was not aware of that command. Makes me wonder how many
other commands there might be that I could use...
- 12-20-2010 #4Just Joined!
- Join Date
- Mar 2008
- Posts
- 28
dieterhansbritz, try these rysnc commands.
Rysnc with resume:
rsync -r --partial --progress --append --rsh=ssh /media/mounteddrive /media/mounteddrivebackup
Rysnc with resume, delete empty directories and extra files and directories that no longer exist from the source that currently exists on the destination.
rsync -r --partial --progress --append --prune-empty-dirs --delete
- 12-20-2010 #5Just Joined!
- Join Date
- Dec 2010
- Posts
- 1
I have this in my backup script:
cp -v --update -p -r $1/* $2
and it does exactly what you (and I) want. I would suggest you look for some other reason why it isn't working.
Don
- 12-21-2010 #6
Just throwing in a wild guess. Sorry, no time to look through the source now

May it be so that cp checks not only files, but also directories when run with -u? In that case, if you create a new file in a directory, it will copy the entire directory, because the modification time of the entire directory has changed.
rsync should cope better with the problem, though
- 12-21-2010 #7
- 12-21-2010 #8


Reply With Quote
