On MacOS use following command: brew install rsync That’s it! Linux rsync is ready to sync data, perform file transfers and delete files. You can check if the installation was successful using the previously mentioned command: rsync -version How to Use Rsync Commandsįor this tutorial, we will create two directories on our Linux desktop with the names original and duplicate. The original directory has three files in it while the duplicate is empty. The output will look similar to this: file1 If you want to double-check, use the ls command to list all the files inside the directory: ls original To create two test directories use the following commands: cd ~ Now let’s see how rsync will create new ways to increase productivity. If you use the ls command with the directory duplicate, the outlook should be empty. Now that the directories are set up, let’s try out a few more commands. The following command will copy or sync all files in the original directory into the duplicate directory. * instructs the rsync command to synchronize everything in the original directory to the duplicate. If we place a new image or file in the original folder and rerun the same command, only the new image will be copied to the destination. Here is a list of the most common commands used with rsync: This feature is handy when you are copying files over a network with limited bandwidth. This gives you a visual output that shows the progress of the process. This compresses the file data during the transfer. This is to copy data recursively -r How to Use Rsync Commands With Subdirectories If you want to copy the subdirectories as well, you will need to use this command: rsync -r original/ duplicate/ Keep in mind that the above command will only copy files from the original folder’s main directory, and not any of the subdirectories. The -r ( –recursive) option tells rsync to copy everything, including subdirectories and the files from our original folder. The / modifier used after original instructs rsync to copy the contents of the original directory to the duplicate folder.
0 Comments
Leave a Reply. |