Page 1 of 1

Loại bỏ files và folder khi thực hiện tạo file nén tar

PostPosted:09 Jun 2018 15:57
by nguyenoanh
Lệnh tar tạo file nén:
Code: Select all
tar czf website.tar.gz –exclude “cache” public_htm
Lệnh trên sẽ nén tất cả các file và folder trong thư mục public_html và loại trừ tất cả các files/folder có ký tự cache trong tên của nó.

Ví dụ:

1. Loại bỏ các files/folders có ký tự backup trong đó:
Code: Select all
tar czf website.tar.gz --exclude "*backup*" public_html
2. Loại bỏ các folder và files ẩn ( tên bắt đầu bằng ký tự "." )
Code: Select all
tar czf website.tar.gz --exclude ".*" public_html
3. Loại bỏ folder only
Code: Select all
cd /folder_to_backup
tar --exclude='./folder' --exclude='./upload/folder2' -zcvf /backup/filename.tgz .