From 5e4859050ae4c6cbcf0ff69f5f30723a72827d8e Mon Sep 17 00:00:00 2001 From: root Date: Sat, 6 Sep 2025 00:09:52 +0330 Subject: [PATCH] rsync command --- Linux/File Copy & Synchronization/rsync.md | 131 +++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 Linux/File Copy & Synchronization/rsync.md diff --git a/Linux/File Copy & Synchronization/rsync.md b/Linux/File Copy & Synchronization/rsync.md new file mode 100644 index 0000000..72ecd4e --- /dev/null +++ b/Linux/File Copy & Synchronization/rsync.md @@ -0,0 +1,131 @@ +# πŸ”„ Rsync + +`rsync` is a powerful command-line tool for syncing files and directories between systems over SSH. +Here are some useful commands πŸ‘‡ + +--- + +## πŸ“Œ Basic Syntax + +```bash +rsync [options] @: +``` + +or + +```bash +rsync [options] @: +``` + +--- + +## πŸ“₯ Copy from Local ➝ Remote + +```bash +rsync file1.txt radin@192.168.1.10:/home/radin +``` + +Verbose mode (shows details): + +```bash +rsync -v file1.txt radin@192.168.1.10:/home/radin +``` + +--- + +## πŸ“€ Copy from Remote ➝ Local + +```bash +rsync -v radin@192.168.1.10:/home/radin/file1.txt /opt +``` + +--- + +## πŸ“¦ Archiving + +Archive mode (preserves permissions, symlinks, etc.): + +```bash +rsync -va file1.txt radin@192.168.1.10:/home/radin +``` + +Archive + compress (gzip): + +```bash +rsync -vaz file1.txt radin@192.168.1.10:/home/radin +``` + +With progress bar: + +```bash +rsync -vaz --progress file1.txt radin@192.168.1.10:/home/radin +``` + +--- + +## πŸ” Custom SSH Port + +```bash +rsync -e 'ssh -p 8090' -vaz file1.txt radin@192.168.1.10:/home/radin +``` + +--- + +## πŸ—‘οΈ Sync with Delete (mirror directories) + +Deletes files on destination that don’t exist on source: + +```bash +rsync -vaz --delete dir_test/ radin@192.168.1.10:/home/radin +``` + +--- + +## 🚫 Excluding Files + +Exclude `.img` files: + +```bash +rsync -va dir_test/ --exclude '*.img' radin@192.168.1.10:/home/radin +``` + +--- + +## ⚑ Bandwidth Control + +Limit transfer speed (in KB/s): + +```bash +rsync -v --bwlimit=2048 file1.txt radin@192.168.1.10:/home/radin +``` + +--- + +## 🧹 Move Instead of Copy + +Remove source file after transfer: + +```bash +rsync -v --remove-source-file file1.txt radin@192.168.1.10:/home/radin +``` + +--- + +## β›” Ignore Existing Files + +Skip already existing files: + +```bash +rsync -v --ignore-existing file1.txt radin@192.168.1.10:/home/radin +``` + +--- + +## πŸ§Ήβ›” Combine Options + +Remove source + ignore existing: + +```bash +rsync -v --remove-source-file --ignore-existing file1.txt radin@192.168.1.10:/home/radin +``` +