[Linux](EN) Copy files to local or remote using rsync

Let’s use rsync command in Linux base OS.


Environment and Prerequisite

  • Linux
  • Bash shell(/bin/bash)


rsync command

Basic

  • rsync : It represents Remote Sync. It is a fast, versatile, remote (and local) file-copying tool which can use with various options
  • It is similar file-copying tool like rcp and scp. It can copy file and directory to not only remote but also local.
  • There are so many options that can be combined for many functions.(preserve symlink, preserve permission, preserve timestamp etc)


Basic Usage

  • Contents from manual page
rsync [options ...] [source] [target]

옵션

  • -v : Increase verbosity. It give more information about copying process.
  • -z : Compress files when copying
  • -h : Print human-readable mode
  • -a (same as -rlptgoD) : Archive mode. It is same as -rlptgoD options. Those options explanation are at below of this option. It copies symlink, permission, timestamp and etc properties.
  • -r : Recurse into directories. Use if for directory copy
  • -l : Copy symlinks as symlinks
  • -p : Preserve permissions
  • -t : Preserve modification times
  • -g : Preserve group
  • -o : Preserve owner(super-user only)
  • -D (same as --devices --specials) : Same as --devices --specials)
  • --devices : This option causes rsync to transfer character and block device files to the remote system to recreate these devices.(root only)
  • --specials : This option causes rsync to transfer special files such as named sockets and fifos.


Examples

  • Local file
# rsync [File Name] [Target Path]

rsync -avzh test_file.txt /tmp
  • Local directory
# rsync [Directory Name] [Target Path]

rsync -avzh test_directory /tmp


# Copy all files in directory
# rsync [Directory Name]/ [Target Path]

rsync -avzh test_directory/ /tmp
  • Remote file
# rsync [File Name] [User]@[IP Address]:[Path]

rsync -avzh test.txt twpower-private-server:~
rsync -avzh test.txt twpower@192.168.1.2:~
  • Remote directory
# rsync [Directory Name] [User]@[IP Address]:[Path]

rsync -avzh test.txt twpower-private-server:~
rsync -avzh test.txt twpower@192.168.1.2:~


# Copy all files in directory
# rsync [Directory Name]/ [User]@[IP Address]:[Path]

rsync -avzh test_directory/ twpower-private-server:~
rsync -avzh test_directory/ twpower@192.168.1.2:~


Reference

[Python] pdb를 이용해 파이썬 코드 디버깅하기

> pdb를 이용해 python 코드를 디버깅하는 방법을 알아보자.## 환경- Linux 기반 시스템- Bash shell(/bin/bash)- Python## pdb### pdb란?- ```pdb``` : 파이썬 디버깅 도구로 파인썬 인터프리터...… Continue reading