Ubuntu – Where do files rsynced to a host go


I accidentally rsynced .thunderbird to user@host instead of to user@host:/home/user.

Where is .thunderbird now? Is there a good way to search for the folder?

Best Answer

It's in the directory where you ran the command:

$ touch foo
$ ls -l foo bar@baz
ls: cannot access 'bar@baz': No such file or directory
-rw-rw-r-- 1 muru muru 0 May 30 16:53 foo
$ rsync -aP foo bar@baz
sending incremental file list
              0 100%    0.00kB/s    0:00:00 (xfr#1, to-chk=0/1)
$ ls -l foo bar
-rw-rw-r-- 1 muru muru 0 May 30 16:53 bar@baz
-rw-rw-r-- 1 muru muru 0 May 30 16:53 foo

If you did rsync .thunderbird user@host: and not rsync .thunderbird user@host (note the :), then the directory was copied to the home directory of user on host (so /home/user would usually be redundant in user@host:/home/user). Without the :, the second argument is just the path to a target directory on the local system.

The same applies to scp.

Note that rsync does not delete source files unless you tell it to. So .thunderbird is still where it was, and a new copy is made wherever it was copied to.

Also note that rsync has different behaviour based on whether the source directory had a trailing /. These two are different:

rsync -aP .thunderbird somewhere
rsync -aP .thunderbird/ somewhere

In the first case, the .thunderbird directory is copied somewhere, but in the second case, the contents of .thunderbird are copied (so you won't see somewhere/.thunderbird, but if there was a .thunderbird/foo, you'd see somewhere/foo instead of somewhere/.thunderbird/foo).