반응형
Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- mybatis
- Netty
- JPA
- weblogic 10
- Airflow
- Hibernate
- KAFKA
- vue.js
- WebLogic
- netflix oss
- cassandra
- spring boot redis
- argo cd
- RabbitMQ
- coalesce
- Docker Compose
- QueryDSL
- Spring Open Feign
- grafana
- docker compose mysql
- spring cloud
- Selenium
- Redis Sentinel
- ChannelPipeline
- docker-compose
- spring boot
- MySQL
- jmeter
- docker
- redis
Archives
- Today
- Total
IT.FARMER
linux scp , rsync 본문
반응형
scp , rsync. linux
데이터 베이스 백업
mysqldump -u [사용자 계정] -p [패스워드] [원본 데이터베이스명] > [생성할 백업 DB명].sql
mysqldump -u aereport -p ae_report > ae_report.20220502.sql
SCP 파일 전송
scp 와 rsnc의 가장큰 차이첨은 속도라고한다. 또한 이름그대로 scp 는 심플하게 카피만 하고 끝나며, rsync 는 변경된 파일들이 있으면 변경된 파일까지 같이 씽크를 맞춰 준다.
scp -P [서버포트] [보낼파일명] [서버계정]@[서버ip]:[받을경로]
option
r : 하위 폴더를 포함하여 모두 복사(Recursive)
p : 권한 및 속성을 유지(Preserve)
c : 압축 옵션(Compress)
[mezzo@AErepoDB-12-91 backup]$ scp -P 7723 ae_report.20220502.sql mezzo@192.168.0.1:/home/mezzo/dbbackup
The authenticity of host '[192.168.0.1]:7723 ([192.168.0.1]:7723)' can't be established.
RSA key fingerprint is 74:2d:43:a7:cf:fe:c1:3a:31:52:c4:97:05:e7:1c:9b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[192.168.0.1]:7723' (RSA) to the list of known hosts.
Caution!!!!
Your behavior is being monitored.
mezzo@192.168.0.1's password:
ae_report.20220502.sql
데이터 복원
mysql -u [사용자 계정] -p [패스워드] [복원할 DB] < [백업된 DB].sql
mysql -u aereport -p ae_report < ae_report.20220502.sql
rsync (remote synchronization)
원격(로컬)에 있는 파일과 디렉터리를 복사하고 동기화 하는 방식
rsync [옵션] [대상] [목적지]
## Local > Local
## /var/lib/mysql 디렉토리를 /home/skan/backups 으로 백업 하기
rsync -azvh /var/lib/mysql /home/skan/backups
Local→ Remote
rsync [옵션] [대상] [서버로그인아이디@도메인(아이피):목적지폴더]
Local 의 /var/lib/mysql 폴더를 192.168.0.7의 /home/skan/backups 폴더로 씽크
rsync -azP /var/lib/mysql testuser@192.168.0.7:~/home/skan/backups
rsync -azP --rsh="ssh -p7723"
옵션
a : 권한 소유주 및 위치까지 그대로 가져옴(Archive)
v : 동기화 상세 진행상항 나타냄(Verbose)
r : 하위 폴더를 포함하여 모두 복사(Recursive)
p : 원본 파일 시간의 수정시간, 권한 등 정보 보존(Perms)
z : 데이터 압축 전송(Compress)
Remote→ Local
rsync [옵션] [서버로그인아이디@도메인(아이피):대상] [목적지폴더]
차이점
- rsync 최초에 모든 파일과 폴더를 복사하고 이후에는 변경된 파일만 복사한다. scp는 파일을 단 한번만 전송한다.
- scp 는 전송하는 파일중에 심볼릭링크가 있어도 이를 유지 하지 않고 링크된 원본파일을 전송한다.
반응형