#!/linuxSucks/Rsync Command to transfer and sync data to remote or host machines
Jun 26, 2021rsync – a fast, versatile, remote (and local) file-copying tool
Install Rsync
Arch Linux
sudo pacman -S rsync
Debian
sudo apt install rsync
Void Linux
sudo xbps-install rsync
Rsync is in most/all Linux distros repositories
Syntax
Local to Local: rsync [OPTION]... [SRC]... DEST
Local to Remote: rsync [OPTION]... [SRC]... [USER@]HOST:DEST
Remote to Local: rsync [OPTION]... [USER@]HOST:SRC... [DEST]
- OPTION - The rsync options .
- SRC - Source directory.
- DEST - Destination directory.
- USER - Remote username.
- HOST - Remote hostname or IP Address.
Examples
Copy all file in the Documents directory to an external ubs ssd/hhd in a local host
rsync -a ~/Documents/* /mnt/backup
Every time the command runs will copy/transfers only the new data or data that has been updated in the documents directory
Copy files in a local host to and external ssd/hdd usb
rsync -azP ~/Music/* user@xxx.xxx.xxx.xxx:~/Music
To copy/update a website in a remote server
rsync -azP ~/Documents/web/public/* user@domain.xxx:/var/www/domain.xxx
To copy/update a backup from a remote server
rsync -azP user@damain.xxx:/var/www/domain.xxx/* ~/Documents/backupweb
You can use and ip address or a domanin name with srync command, if the directory do not exist in the destination host rsync will create the directory
Rsync use ssh protocol to connect to a remote host, if the remote host is listenling on different port (22)
rsync -azP -e "ssh -p 2343" ~/Documents/web/public/* user@domain.xxx:/var/www/domain.xxx
For more info and options, man rsync