tar 归档文件
tar -cvzf test.tar.gz 要归档的文件名或目录 --exclude=排除的文件或目录
tar -cvzf test.tar.gz ./ --exclude=test
tar 增量备份
mkdir test
cd test
mkdir ./{a,b,c}
tar -cf test.tar --exclude=test.tar
增加文件d 和 在a中写入东西
touch d
echo "1" > a
更新test.tar
tar -uf test.tar ./ --exclude=test.tar
ll test
-rw-r--r-- 1 root root 4 10-03 20:57 a
-rw-r--r-- 1 root root 0 10-03 20:55 b
-rw-r--r-- 1 root root 0 10-03 20:55 c
-rw-r--r-- 1 root root 0 10-03 20:57 d
-rw-r--r-- 1 root root 10240 10-03 20:57 test.tar
find ./ -type f -name "[a-z]" -exec rm -f {} \;
ll test
-rw-r--r-- 1 root root 10240 10-03 20:57 test.tar
tar -tvf test.tar
drwxr-xr-x root/root 0 2012-10-03 20:57:14 ./
-rw-r--r-- root/root 0 2012-10-03 20:55:18 ./c
-rw-r--r-- root/root 0 2012-10-03 20:55:18 ./b
-rw-r--r-- root/root 0 2012-10-03 20:55:18 ./a
drwxr-xr-x root/root 0 2012-10-03 20:57:26 ./
-rw-r--r-- root/root 0 2012-10-03 20:57:26 ./d
-rw-r--r-- root/root 4 2012-10-03 20:57:35 ./a
tar -xvf test.tar
ll test
-rw-r--r-- 1 root root 4 10-03 20:57 a
-rw-r--r-- 1 root root 0 10-03 20:55 b
-rw-r--r-- 1 root root 0 10-03 20:55 c
-rw-r--r-- 1 root root 0 10-03 20:57 d
-rw-r--r-- 1 root root 10240 10-03 20:57 test.tar
阅读(344) | 评论(0) | 转发(0) |