31

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 ?

1 Answer 1

40

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).

7
  • 2
    Copy is OK, can always remove the old directory later. Commented Jun 1, 2012 at 16:02
  • 9
    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. Commented May 5, 2014 at 2:43
  • 2
    so as an example of a move: rsync --remove-source-files --recursive --times --crtimes 1/* 2/ Commented Oct 7, 2014 at 4:35
  • 3
    @deltab, --progress draws a new bar for each individual file, instead there is --info=progress2 for the whole tranfer. Commented Mar 8, 2017 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. Commented Mar 2, 2019 at 14:15

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.