About rsync
Rsync, which stands for “remote sync” enabled by defaults in every linux system.
Sync two directories with rsync command local host
rsync -r directory1/ directory2
-r = recursively sub directory as well
-a = archive symlics . files etc
trailing slash (/) – helps to avoid directory1 name inside directory2
rsync -a directory1/ directory2
rsync -anv dir1/ dir2
-v verbose print
-n
–dry-run – nothing happens
Rsync to Sync with a Remote System
rsync -av –delete -e ssh /localdirectory/ geek@192.168.235.137:/remotedirectory/
push or send example from local to remote
rsync -a ~/directory1 username@remote_host:destination_directory
pull command remote to local sync
rsync -a root@remote_host:/home/root/dir1 place_to_sync_on_local_machine
Create a crontab for rsync every 15 minutes – auto backup
crontab -e
I
0 22 * * * rsync -av –delete /Directory1/ /Directory2/
delete files from the destination directory if they are removed from the source
sync -a –delete source destination
rsync to backup directory
rsync -a –delete –backup –backup-dir=/path/to/backups /path/to/source destination
rsync windows to linux
most of all use windows and linux servers, so we can use window command line terminal
connect windows command line to linux server
Cygwin
Rynsc vs scp
SCP only copies no auto sync one time use.