Experimenting with a Raspberry Pi 5, I tried to sync some files from the Pi to my Ubuntu 22.04 Desktop.
Once you have setup ssh-keys with ssh-copy-id, and added an entry to .ssh/config you can easily connect to your pi with
ssh pi
using rsync on the Raspberry Pi
Copying a file or directory can be done with rsync:
rsync pi:pathtofile/file.txt .
Now the file will be copied to your working directory (directory your running the command from)
rsync will magically autocomplete the path in the same way it does for local path by pressing tab.
I have a dir called `new map` on my pi. It contains a space.
When I type `rsync pi:new` and press TAB rsync will auto-complete it to `rsync pi:new\\\ map`
It will double-escape the path.
But executing the command after auto-completion does not work:
rsync pi:new\\\ map .
rsync: [sender] link_stat "/home/pi/new\ map" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1865) [Receiver=3.2.7]
rsync: [Receiver] write error: Broken pipe (32)
Using spaces in maps of file-names is a nasty thing that should be avoided. Sooner or later it will give you troubles.
As it seems newer versions of rsync (> 3.2.4) do NOT require double escaping anymore, but the auto-completion still uses it.
This is clearly a bug:
https://github.com/scop/bash-completion/issues/848
Use the –old-args argument for rsync to fix auto-complete double escaping
The workaround is to use the –old-args argument for rsync
rsync --old-args pi:new\\\ map
Now it is working fine, I suppose this will be fixed in a newer version of rsync.
Tags: rpi