Originally Posted by
MariosFFX
And I ended up with empty directories. The above command deleted the files from the destination as well as from the source.
To accomplish that, I would have used rm instead. Much clearer.
If you want to restore files, use the backup you made before doing anything risky.
Linux (and rsync) follows the UNIX philosophy, which simply asks, "can I do what was asked?" The program doesn't know if what is being asked is brilliant or stupid, just whether it can take the inputs, honor the options, and create the outputs from those options and inputs. Seems to me, it did what you asked.
You do know about the --dry-run option for rsync, right?
Some key things in the rsync manpage:
Code:
--remove-source-files sender removes synchronized files (non-dir)
--delete delete extraneous files from dest dirs
--delete-before receiver deletes before xfer, not during
--delete-during receiver deletes during the transfer
--delete-delay find deletions during, delete after
--delete-after receiver deletes after transfer, not during
--delete-excluded also delete excluded files from dest dirs
--dry-run, -n perform a trial run with no changes made
So it appears that then each option is checked matters.
Also, when doing destructive things, it is important to read all the caveats in the manpage to ensure there aren't any unintended consequences.
If you just want to move files, across file systems, I'd use the 'mv' command, not rsync. There are a number of ways to locally mount remote storage, if it isn't on the same computer. sshfs would be the worst case, though I wouldn't expect symbolic links to be correct after the move.
Bookmarks