Lệnh phổ thông công dụng đại học, bạn sẽ dùng nhiều khi
- Deploy code
- Gửi file
- Chuyển thư mục qua lại các ổ đĩa
Nhớ là chỉ chơi với môi trường linux
Chưa rõ thì dùng trợ giúp
rsync --helpĐơn giản
rsync -a dir1/ dir2Phức tạp hơn, chuyển file từ máy tính lên server
rsync -a ~/dir1 username@remote_host:destination_directory
rsync -a username@remote_host:/home/username/dir1 place_to_sync_on_local_machineSử dụng với ssh
Không có key
rsync -avz -e ssh remoteuser@remotehost:/remote/dir /this/dir/Có kèm key pem
rsync -avz -e "ssh -i /home/thisuser/cron/thishost-rsync-key" remoteuser@remotehost:/remote/dir /this/dir/Tham khảo thêm tại
https://en.wikipedia.org/wiki/Rsync
https://explainshell.com/explain?cmd=rsync+-a+-x+-u+-v+
Mấy tham số quan trọng
rsync -azP source destinationLưu ý : ký tự "/" ở cuối directory, bạn sẽ mất hết dữ liệu chỉ bởi 1 ký tự
rsync -a --delete source destination
rsync -a --exclude=pattern_to_exclude source destination
rsync -a --exclude=pattern_to_exclude --include=pattern_to_include source destination

Nhận xét
Đăng nhận xét