簡體   English   中英

如何排除`.git`然后備份和恢復文件夾和文件的所有者和權限?

[英]How to exclude `.git` then backup and restore folders and files owner and permission?

我更喜歡使用 bash 腳本,因為getfacl,setfacl有大問題(bug)。

在問這個問題之前,我還搜索了一種純bash腳本的方法來備份和恢復owner and permission可惜沒有人承認完美的答案。

然后我使用一種簡單的方法來備份和恢復所有者和權限:

getfacl -R . >permissions.facl
setfacl --restore=permissions.facl

如果我要排除.git. ,怎么做?

是的你可以。

例如,我的目錄看起來像

[root@967dd7743677 test]# ls -la
total 20
drwxr-xr-x 4 root root 4096 Jan 11 06:37 .
drwxr-xr-x 1 root root 4096 Jan  2 11:08 ..
drwxr-xr-x 8 root root 4096 Jan  2 12:56 .git
drwxr-xr-x 2 root root 4096 Jan 11 06:37 1one
-rw-r--r-- 1 root root   19 Jan  2 12:55 testfile
[root@967dd7743677 test]#

通過使用find你可以排除任何你想要的目錄

find . -type f -not -path '*/\.git/*' -exec getfacl -R {} \;

所以通過-exec我們調用getfacl -R

你可以重定向輸出

find . -type f -not -path '*/\.git/*' -exec getfacl -R {} \; > permissions.facl

希望能幫助到你。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM