Posted On August 24, 2021

Linux: RSYNC Examples

kimconnect 0 comments
blog.KimConnect.com >> Linux >> Linux: RSYNC Examples

Following are a few practical uses of this command:

# Copying from a Local Directory to another
# Important: to set source and destination directories, one must include the trailing slash '/' to identify object as a directory
source=/media/kim/2849-2EAD/doanclub_kimconnect/
destination=/media/data/doanclub_kimconnect/
rsync -a $source $destination

# Copying in to a directory that does NOT yet exist
# Note: these extra switches would display progress
localsource=/var/lib/docker/
localdestination=/nfs-share/linux03/docker/
mkdir -p $localdestination && rsync -avhP --stats --progress $localsource $localdestination

# Copying with exclusions
source=/media/kim/2849-2EAD/
excludeDirectory=.Trash-1000
destination=/media/data/
rsync -a --exclude=$excludeDirectory $source $destination

# Copying from a Local Directory to a remote machine
rsync -a /media/data/ remote_user@remote_host_or_ip:/media/data/

# Copying from Local to Remote using uncommon port
rsync -a -e "ssh -p 22222" /media/data/ remote_user@remote_host_or_ip:/media/data/

# Copying from Remote to Local
rsync -a remote_user@remote_host_or_ip:/media/data/ /media/data/

# Copying from Remote to Local using a 'screen' session (terminal multiplexer)
rsync -a -P remote_user@remote_host_or_ip:/media/data/ /media/data/

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

Some MySQL Admin Stuff

make sure it's running ps -ef | grep mysql Creating MySQL DB HOWTO on creating…

Git / Github / Gitlab

1. Install Git/Github/Gitlab This utility enables cloning of source codes to the local machine, among…

How to Install Visual Studio Code on Linux Mint 20.04

Linux Mint versions earlier than 20.04 would allow a user to install snapd, prior to…
Other project: DragonCoin.com