10 examples in 11 days
Yesterday on Day 07 I showed how we can sync files from our local machine to our remote machine using ssh. Today is the other way around. I will request a file from remote to local.
The syntax it's almost the same one from yesterday, the difference between yesterday's and the the one I am using today is that with the one below, I will not remove my remote file and the yesterday's source will be our destination and our destination will be yesterday's source. Let's remember the syntax and let me describe it to you so you can see by your self what I am talking about:
Note: As yesterday I will not show the local nor remote machines IP. Instead I will always display 22.214.171.124 IP as remote and 126.96.36.199 as local
iamgroot@laptop:~$ rsync (1)--progress (2)-vhre (3)ssh (4)email@example.com:(5)[remote folder]/(6)[remote file] (7)[local folder to download]
Let's see what the above syntax does:
- --progress: shows progress while synching
- I used -vhre options
- -v: verbose
- -h: human readable
- -r: recursive
- -e: allows us to use ssh as remote shell and execute its commands
- ssh: invoking the ssh service to be used as remote shell.
- ssh connection parameters
- remote folder with full path
- remote file to download
- local folder where the remote file will be downloaded
Note: If the local folder doesn't exist it will be created
I created a folder called download-folder in my remote instance and inside of it I created a file called file_download.txt. I will download this file into my ~/Sync folder that we have been using.
iamgroot@remote-instance:~$ mkdir download-folder && touch download-folder/file_download.txt && echo "Hello World I will be downloaded" >> download-folder/file_download.txt
Now let's sync from remote to local
iamgroot@laptop:~$ rsync --progress -vhre ssh firstname.lastname@example.org:download-folder/file_download.txt ~/Sync receiving incremental file list file_download.txt 12 100% 11.72kB/s 0:00:00 (xfr#1, to-chk=0/1) sent 43 bytes received 113 bytes 34.67 bytes/sec total size is 12 speedup is 0.08
Let's check if it got downloaded
iamgroot@laptop:~$ ls Sync/ file1.txt file2.txt file3.txt file_download.txt
As you can see so far, rsync is a great tool to keep your files sync locally and remotely.
We are almost ending this series, hope you all readers are enjoying it, let me know if you have any doubt and I will be more than happy to help.
Thanks for reading, keep it safe!!
Follow, ❤ or 🦄