I have moved (mv) a pretty large directory on my NAS (Linux based), but had to interrupt the procedure. Not being a regular Linux user, I though I could just continue and merge the rest later in.

mv /oldisk/a /newdisk

Procedure is halfway done, so rest of /oldisk/a still exists, and /newdisk/a with the already copied files is already present. I have no idea which files have been already copied. BTW, under /oldisk/a, of course, are plenty of sub directories.

What would be the best way to move / merge the remaining files to /newdisk/a ?


rsync --verbose --archive --dry-run /oldisk/a/ /newdisk/a/

The --dry-run (or -n) will do a dry run, showing you what it would do without actually doing anything.

If it looks ok, run the rsync without the -n option.

This will be a copy, not a move, which isn't quite what you're doing, but is safer. The --archive (or -a) ensures all the ownership and timestamps metadata is preserved (which a regular copy would not).

  • 2
    Copy is OK, can always remove the old directory later. – Horst Walter Jun 1 '12 at 16:02
  • 7
    You can use --remove-source-files to delete the files that have been successfully copied. Also, -P or --progress will show an estimate of how many more files there are to do. – deltab May 5 '14 at 2:43
  • 1
    so as an example of a move: rsync --remove-source-files --recursive --times --crtimes 1/* 2/ – Sridhar Sarnobat Oct 7 '14 at 4:35
  • 1
    @deltab, --progress draws a new bar for each individual file, instead there is --info=progress2 for the whole tranfer. – 把友情留在无盐 Mar 8 '17 at 0:34
  • 2
    Wow, that is pretty sad. Mv is definitely broken that it needs other tools to do what it should be able to do by itself. I just found this out, mv refuses to write into an existing directory, which is pretty pathetic. Time to replace this command with something more functional. – Markus Bawidamann Mar 2 '19 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.