I have been playing around with chmod, chown, setfacl and special bits trying to get multiple system/full users in same group correct access permissions to my media collection.

But I’ve messed it up somehow and now I’m having weird problems that are hard to track.

I would like to set my whole collection back to the defaults.

What is the best way to do this?

One problem I’ve had when making changes to so many files is the process seems to go forever without completing. Eventually it gets killed so my filesystem has variable attributes throughout. how can this be worked around?

I want everything to be owned by myuser, group media, everything else default I will sort it from there once I have a fresh slate.

And is there a way to backup these attributes only? I don’t have enough storage to backup the files themselves.

It is Debian with ext4 filesystem.

Edit to add: Media collection is on its own separate drive/filesystem; this has no impact on anything else on the computer.

    • r00ty
      link
      fedilink
      213 days ago

      Yeah. Only on my phone right now but will get it and post here later/tomorrow.

    • r00ty
      link
      fedilink
      112 days ago

      OK so it’s fairly simple. You need to install the acl package (or whatever equivalent package contains getfacl/setfacl. Then you can use that to dump the data from an entire structure into a file (I also then bzip that). Then I backup all installed packages to help with a restore too.

      So the script looks like:

      #!/bin/bash
      cd /etc
      /usr/bin/getfacl -R . | /usr/bin/bzip2 -9 >PERMISSION_BACKUP.bz2
      chmod 600 PERMISSION_BACKUP.bz2
      cd /home
      /usr/bin/getfacl -R . | /usr/bin/bzip2 -9 >PERMISSION_BACKUP.bz2
      chmod 600 PERMISSION_BACKUP.bz2
      cd /root
      /usr/bin/getfacl -R . | /usr/bin/bzip2 -9 >PERMISSION_BACKUP.bz2
      chmod 600 PERMISSION_BACKUP.bz2
      cd /var
      /usr/bin/getfacl -R . | /usr/bin/bzip2 -9 >PERMISSION_BACKUP.bz2
      chmod 600 PERMISSION_BACKUP.bz2
      /usr/bin/apt list --installed | /usr/bin/bzip2 -9 >/root/INSTALLED-PACKAGES.bz2
      chmod 600 /root/INSTALLED-PACKAGES.bz2
      

      To restore you change to the folder the backup was taken from, unbzip the file (or uncompress live via pipe) and use setfacl --restore=<file>

      • layzerjeytOP
        link
        fedilink
        112 days ago

        thanks for getting back to me. :)

        I am curious what kind of situation would screw up your /etc/ directory?

        • r00ty
          link
          fedilink
          112 days ago

          It’s for backup purposes mainly. A lot of cloud backup providers don’t store permissions.

          So if I restore the data I can then restore the permissions after. So these are the folders I am backing up (with some exceptions in /var)

          • layzerjeytOP
            link
            fedilink
            112 days ago

            Ah I see. Thanks! The data and the attributes are stored separately.