This time it's about how to use rsync. By the way, I'm doing this verification on Bash on Ubuntu on Windows, so it can be used without problems by those using Bash on Ubuntu on Windows.
I was thinking of doing this with [xserver], but I couldn't due to the bug mentioned later, so I'll try it with [conoha], which I recently contracted and haven't touched at all.
How to use rsync
Sync src on remote to dst locally $ rsync -av -e ssh [user]@[host]:./src/ dst Sync src locally to dst on remote $ rsync -av -e ssh ./src/ [user]@[host]:dst
rsync to conoha’s VPS
You can do it like this.
rsync -av -e "ssh" -r "/mnt/c/ContaCam/Logicool HD Pro Webcam C920/2018/" root@YOUIPADDR:/root/lib/contacam
By the way, in this example, the assumption is to automatically upload videos captured by contacam to the server.
Even if an intruder destroys the computer, or the computer burns in a fire, you can check the video later. Peace of mind.
:~/lib# ls contacam/2018/01/31/確認済み/
det_2018_01_31_08_23_53.gif det_2018_01_31_08_24_12.gif det_2018_01_31_08_26_38.gif det_2018_01_31_08_28_57.gif rec_2018_01_31_16_17_52.mp4
det_2018_01_31_08_23_53.mp4 det_2018_01_31_08_24_12.mp4 det_2018_01_31_08_26_38.mp4 det_2018_01_31_08_28_57.mp4
Yes, both folders and files are properly backed up.
rsync to xserver
rsync -av -e "ssh -p 10022 -i ~/.ssh/yuis.key" -r "/mnt/c/ContaCam/Logicool HD Pro Webcam C920/2018/01/31" [email protected]:/home/yuis/yuis.xsrv.jp/public_html/contacam/
It hasn't succeeded, so it might not work. Probably works though. If .bashrc isn't messy.
Error 1: Permission denied (publickey,gssapi-keyex,gssapi-with-mic). rsync: connection unexpectedly closed (0 bytes received so far) [sender] rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.1]
Permission denied (publickey,gssapi-keyex,gssapi-with-mic). rsync: connection unexpectedly closed (0 bytes received so far) [sender] rsync error: unexplained error (code 255) at io.c(226) [sender=3.1.1]
The cause of this error seems to be that SSH connection settings aren't configured properly. For example, the port is 10022 instead of 22 but that's not set, or a private key file is needed but not set.
I'm using [xserver], so to explain using xserver as an example, xserver uses port 10022 and public key cryptography.
So the rsync command would look like this.
rsync -av -e "ssh -p 10022 -i ~/.ssh/yuis.key" -r "/mnt/c/ContaCam/Logicool HD Pro Webcam C920/2018/01/31" [email protected]:/home/yuis/yuis.xsrv.jp/public_html/contacam/
This gives the aforementioned error.
rsync -av -e "ssh" -r "/mnt/c/ContaCam/Logicool HD Pro Webcam C920/2018/01/31" [email protected]:/home/yuis/yuis.xsrv.jp/public_html/contacam/
Error 2: protocol version mismatch — is your shell clean?
protocol version mismatch -- is your shell clean?
(see the rsync man page for an explanation)
rsync error: protocol incompatibility (code 2) at compat.c(180) [sender=3.0.7]
The cause of this error is .bashrc.
There's no (fundamental solution).
As a solution, please refer to the following.
rsync does not work on a remote server with a .bashrc file.
On a local client, when running rsync:
protocol version mismatch -- is your shell clean? (see the rsync man page for an explanation) rsync error: protocol incompatibility (code 2) at compat.c(180) [sender=3.0.7]
You can fix this by removing the command that outputs text in .bashrc, or by piping the output to /dev/null.
As you can read, you should delete .bashrc, remove unnecessary code, or pipe to /dev/null (I don't understand well).
I didn't want to do any of these, so I reluctantly used conoha.