Skip to content

Instantly share code, notes, and snippets.

@shreewatsa
Last active February 22, 2023 09:48
Show Gist options
  • Save shreewatsa/82fc3f6b964244eff774381d561ca031 to your computer and use it in GitHub Desktop.
Save shreewatsa/82fc3f6b964244eff774381d561ca031 to your computer and use it in GitHub Desktop.
Rsync Cheatsheet

Rsync (Remote sync):

Backup, mirrorring, restoring tool. Uses delta transfer algorithm to only send changes instead of whole file, thereby reducing network load.
Syntax: $rsync [options] <source_destination> <remote_destination>;

Usages:

$rsync -avr --exclude="*.pyc" --exclude="static" remote_host:/opt/backup/ .;  # Pulling from remote to local.
$rsync -avr . remote_host:/opt/backup/;                                       # Pushing from local to remote.

Flags:

-a : archive the contents while synchronizing.
-v : verbose output.
-r : recursive through directories.
-n : dry run.
-h : human readable outputs in STDOUT.
--progress : show sync progress.

Extras:

$ctags -R --extra=+f --exclude=’static’;                        # Generate ctags for vim after the rsync.
(vim) :map <C-b> :w<CR>:!rsync -avr localpath remotepath<CR>    # Auto rsync to remote on pressing Control+b shortcut in vim.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment