Linux

tar 압축 및 해제 (또는 압축 시 제외폴더 선정)

제주도 조랑말 2024. 5. 8. 15:17
728x90

압축
tar -cvf [압축폴더 파일명.tar] [압축할 폴더명]

ex) tar -cvf backup.tar thisfolder

 

만약에 특정 디렉토리 제외 압축할 경우 (여기선 /etc/file/을 제거 후 압축)

ex) tar -cvf backup.tar --exclude=' etc/file/' foldername/

절대경로는 절대 안되며

상대경로로 작성해야한다.

/www/include/file/일때 file을 삭제하고 싶으면

/폴더까지 들어가서 

tar -cvf backup.tar --exclude='include/file/' www을 하면된다

 

tar -cvf backup.tar --exclude=www/wms/include/file www

만약 현재 내가 있는 위치가 www와 같아야하며, www/wms/include/file/안에있는 모든 것들을 제외하고 싶다면
위 코드와 같이 실행시킨다.

 

압축해제

tar -xvf 압축폴더 파일명.tar

tar -xvf backup.tar

728x90