---
# System prepended metadata

title: 'Compression, packaging and backup of files and file systems'
tags: [compression]

---

# Compression, packaging and backup of files and file systems

###### tags: `compression`


#  Packaging 打包 tar


多個檔案或目錄包成一個大檔案的指令


```

#打&壓
tar -czvf myetc.tar.gz /etc
#解
tar -xzvf myetc.tar.gz

```

c 打包
x 解包

-z  ：透過 gzip  的支援進行壓縮/解壓縮：此時檔名最好為 *.tar.gz

-v  ：在壓縮/解壓縮的過程中，將正在處理的檔名顯示出來！
-f filename：-f 後面要立刻接要被處理的檔名！建議 -f 單獨寫一個選項


---



### 增量壓縮

tar cvfz


create 
verbose
filename
zip 


![](https://i.imgur.com/Sui9D0O.png)
timeStamp


```
[root@meowhecker centos]# mkdir backup
[root@meowhecker centos]# cd backup/
[root@meowhecker backup]# touch file1 file2 file3 
[root@meowhecker backup]# ls
file1  file2  file3
[root@meowhecker backup]# tar cvfz backupMeow.tar.gz ./*
./file1
./file2
./file3

```


Record update time 

```
touch timeStamp
```

```
find -type f -cnewer timeStamp
./file1
./file4
```

```
tar cvfz backupMeow-2.tar.gz `find -type f -cnewer timeStamp`
./file1
./file4
```


解壓 unzip 

```
tar xvfz backupMeow.tar.gz
```

```
tar xvfz backupMeow-2.tar.gz
```
