How can I copy, recursive directory, only files with a attribute 1, and reset this a attribute to 0? Thanks, Francisco
How can I copy, recursive directory, only files with a attribute 1, and reset this a attribute to 0?
1 Answer
You will probably have to install the package attr
if you want to set and get extended attributes.
You can write a script in a shell language, or a higher level language to descend directories and examine each file, copying the ones that meet your criteria. I would use python, personally.
By using the getfattr command you can retrieve the value for a user.name you define yourself as an extended attribute. After copying the file you could then set a different value by executing the setfattr command.
I don't see an option for rsync or dump to do this. Dump is said to ignore files with the d (non-extended) attribute set. These regular attributes are set with chattr
and attributes are examined with lsattr
. These commands also include setting a version for a file, in case that can be used as a substitute for the bit setting/clearing you are asking about. I suppose you could make the version alternate between 0 and 1 if you like. See man chattr
and man lsattr
and, in particular, the -v option.
The legacy dump
command appears to use a file (/var/lib/dumpdates) of its own to keep track of what has been backed-up when so it can backup incrementally, which may be the sort of thing you are getting at.
It may be helpful to know more about what you are trying to achieve in case there is another approach that doesn't involve programming.