大网数据广告活动
服务器运维问答

Speed up backup of just ACLs on large file systems

· 52CE 我爱测

I'm trying to make quick backups of just the ACLs on large GNU/Linux file systems. Extended permissions are not really necessary. I run 4 little benchmarks on a small partition just to make an estimation of the elapsed time (seco…

问题原文

原帖链接 · Julen Larrucea · CC BY-SA 3.0

I'm trying to make quick backups of just the ACLs on large GNU/Linux file systems. Extended permissions are not really necessary.

I run 4 little benchmarks on a small partition just to make an estimation of the elapsed time (seconds) and produced file sizes (megabytes).

  • getfacl -R -p /backup/dir > out_file: 58.715s (36MB)
  • find /backup/dir -printf "%m %u:%g %p \n" > out_file : 54.053s (27MB)
  • find /backup/dir -printf "%m %p \n" > out_file : 0.763s (26MB)
  • ls -laR /backup/dir > out_file : 4.865s (20MB)

So ls is the best solution if need the user:group.

Ideally, the out_file should look like:

755 user:group /full/path/to/dir
744 user:group /full/path/to/file
...

But as far as I know getting the full path to the file from ls requires extra commands which will slow down the process. We are talking about very big file systems.

Isn't there a better (faster/more efficient) tool than ls to handle this?

Why does find slow down so dramatically when retrieving user:group info in comparison to ls?

As a plus, ls can also handle escaping special characters on filenames (with the -b option).

Solved: (thanks to @shodanshok) First time after sync:

  • getfacl -n -R -p /backup/dir > out_file: 19.561s (36MB)

But the second time running the same command:

  • getfacl -n -R -p /backup/dir > out_file: 2.496s (36MB)

已采纳解答

原帖链接 · shodanshok · CC BY-SA 3.0

In my experience, getfacl can be CPU bound by the username-resolving process. Try adding the -n switch, for example issuing getfacl -n -R -p /backup/dir > out_file

During benchmarks, pay special attention to the inode/dentry cache, as it can easily skew your timed test. Before each benchmark, issue the following command to empty both caches: sync; echo 3 > /proc/sys/vm/drop_caches

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-04-19)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。