Saturday, May 18, 2024

Using "rsync" utility in Linux

"rsync" is a sync utility in Linux but its not bi-directional.

Simple command to run rsync is as below, it will copy folder1 to folder2 which is a backup location.

$ rsync /home/bypramod/folder1 /backup/folder2

Using much better options

$ rsync -rvaz --dry-run /home/bypramod/folder1/ bypramod@127.0.0.1:/storage/backup/folder2/

Options:

-r : recurssive

-v : verbose

-a : archive mode to sync meta data like timestamp of file etc.

-z : to compress during transfer

--dry-run : to estimate how it runs

/ : at end of folder name makes sure under it is copied

--delete : use this to sync from source to target, because as sync is not bi-directional at least this will delete if there are any deleted files in source.

From above remove --dry-run for actual run.

Command:

$ rsync -rvaz /home/bypramod/folder1/ bypramod@127.0.0.1:/storage/backup/folder2/

***

No comments:

Post a Comment