Contents...
Copy missing files with rsync command – We can use rsync command to synchronize files and directories between two computers. We use this command to copy files or directories from one location to another location with preserving file attributes like timestamps, ownership and permissions.
It has has also ability to copy only those files that are missing and have been modified at the destination location. It is also useful command to take backup of your data or to update your website with the latest changes.
You may also like : How to Setup Automatic Remote Backup with rsync command?
In this article I will explain how to copy missing files with rsync command in Linux.
Copy Missing Files with Rsync Command in Linux
We can use the ” –ignore-existing ” parameter to copy missing files with rsync command. This parameter help to skip the files that are existing at destination and only copy missing files from the directories.
Follow this below command to copy missing files with rsync command.
$ rsync --ignore-existing -av source/ destination
Here:
- –a : To preserve its file attributes and
- –v : For verbose mode. It will display the progress of the transfer files that are being copied.
Copy Modified Files with Rsync Command
We can also copy only modified files or new files with rsync command and skip the older files that already exist at the destination. We can use –u or —update parameter with –r or —recursive parameter to copy files recursively.
Follow this below command to copy only modified files.
$ rsync -ur source/ destination/
Copy Files Modified in Last N Days
We can also copy modified files in last N days. For example to copy files only that are modified in last 5 days. We can use –max-age parameter with the number of days.
$ rsync --ignore-existing --max-age=5 -av source/ destination/
Copy Files by Size with Rsync Command
We can also copy files based on its size. We can use –size-range parameter with +SIZE or –SIZE . For example if we want to copy only file that are larger than 50MB we will use this command.
$ rsync --ignore-existing --size-range='+50M' -av sournce/ destination/
Apart from this there are also lots of parameter or option are available with rsync command that can be used to full fill our requirement during file transfer. For example we can use –dry-run parameter for testing purpose without actually coping files.
FAQs
What rsync command is sued for?
Rsync command is used to copy files or directories between to remote or local system. It is very command tool for Linux Admin.
Is rsync is better than scp?
Both command are used to copy file from one location to another location but for good incremental backup other hand scp command is good for securely pushing or pulling the small files between to computers.
When should I used rsync command?
You can use rsync command to transfer large file data between two nodes. Rsync mostly used for copying data, data backup and migrating hosts.
Which is faster SFTP or Rsync?
SFTP transfer the data around 700 Kbps other hand rsync transfer the data at the rate of 1.4 Mbps. As I know SFTP and Rsync both use SSH connection to transfer data. So it does imply rsync is much (2x) faster than SFTP.
On which protocol Rsync work UDP or TCP?
Rsync use ssh connection which use TCP.
If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.
Leave a Comment