I'm trying to copy a large directory from one drive to another. I mistakenly logged out before it was finished so only about 80% of the files copied over. Is there away to copy the remaining files without starting from scratch?
I would try,
rsync -a /from/file /dest/file
you can use other options like
-P (--partial --progress). See man rsync for more info.
Or if you are using
cp then use
-u, --update copy only when the SOURCE file is newer than the destination file or when the destination file is missing.
For partial file transfers,
cp might not be what you need.
I suggest using
rsync instead. Even when transfer fails, you can simply re-run the command at a later time, and it'll copy only the missing files.
$ rsync -aPEmivvz from/ to/
rsync does syncing and checking after each transfer, ensuring files have been copied correctly is trivial.
The swich set
-aPEmivvz is my standard go-to selection, whenever copying files over networks or external drives, including plug-in devices, like SD-Cards, etc.
These are the switches I use almost always:
-a: "archive", includes
-rlptgo (recursive, symlinks as symlinks, permissions, times, group, owner)
-P: "partial progress" shows nice progress bar for each file
-E: "executability" preserve whether executable or not
-m: "noempty" prunes empty dirs
-i: "summary" print change summary for all updates
-vv: "more verbose"
You should not use
cp for this. As others have stated it's not the right tool for the job. The correct tool is going to depend on your goals.
If you just want a straight copy:
rsync /source /destination with some level of flags. See the other answers for some really good examples.
If you want to have bi-directional updates
unison is the way to go. Rsync doesn't do very well at conflict resolution with bidirectional syncs. Specially deletes. So you you want bi-directional copies fire up
If you want backups and the files are text based, then you can try using
git. Git can be run locally, there's no need for a "server". In fact, git servers are only file sharing methods. You could totally have a git repo on the backup drive and "push" to it. Again this only really works if the files are text based and your trying to get a one way backup.
Again if your going for a backup (and not just one time) then look at deja-dupe, BackIntime, or similar options. They take snapshots of the data at a point in time. They all run rsync under the hood.