Synchronise folders between computers with rsync
You can use rsync to synchronise folders between computers. For example, you can use rsync to transfer new pictures taken by your Raspberry Pi to your personal computer automatically.
Before you can configure rsync, determine values for the following:
-
<pi_ip_address>: your Raspberry Pi device’s local IP address. For more information, see Find your Raspberry Pi device’s IP address. -
<pi_username>: the username you use to log into your Raspberry Pi -
<pi_folder_name>: the name of the folder you want to copy files from on your Raspberry Pi -
<pc_folder_name>: the name of the folder you want to synchronise on your personal computer
To configure rsync to synchronise files, complete the following steps on your personal computer, replacing placeholders in the commands with the values you determined above:
-
Create the folder you want to synchronise to:
$ mkdir <pc_folder_name> -
Synchronise files to the folder with
rsync:$ rsync -avz -e ssh <pi_username>@<pi_ip_address>:<pi_folder_name>/ <pc_folder_name>/
This command copies all files from the selected folder on your Raspberry Pi to the selected folder on your personal computer. If you run the command multiple times, rsync keeps track of the files you have already downloaded and skips them. If you delete or modify an already synchronised file on the Raspberry Pi, rsync updates the files on your personal computer accordingly.