Backing Up Permissions

23 views
Skip to first unread message

Paul Boniol

unread,
May 28, 2023, 4:21:56 AM5/28/23
to NLUG
Way back, I should have paid more attention... but I have like 3 TB of video recordings backed up to an external (exfat) hard drive (should have reformatted as ext4 first but I didn't think about it first).

Now I'm preparing to do a fresh Linux install. And I'm wanting to somehow backup the user/group/permissions for the directories and files.

I can look and write them down as most would be the same. Just wondering if there's some better way.

---Paul.

Howard White

unread,
May 28, 2023, 8:56:42 AM5/28/23
to nlug...@googlegroups.com
I have struggled with a similar problem. I have directories of mp3
files in two places: ntfs and ext4. With the demise of iROCK109, I need
to resolve all of the ntfs files as the master copied to the ext4 (on my
NAS) which I share in the house. rsync is messing with me over permissions.

Howard
> --
> --
> You received this message because you are subscribed to the Google
> Groups "NLUG" group.
> To post to this group, send email to nlug...@googlegroups.com
> To unsubscribe from this group, send email to
> nlug-talk+...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nlug-talk?hl=en
> <http://groups.google.com/group/nlug-talk?hl=en>
>
> ---
> You received this message because you are subscribed to the Google
> Groups "NLUG" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to nlug-talk+...@googlegroups.com
> <mailto:nlug-talk+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/nlug-talk/CAL9PgS20P7Ly3%2BXJTDp%2B0jEr9igB8kgVO3-YPfBT5VJhoJAUyw%40mail.gmail.com <https://groups.google.com/d/msgid/nlug-talk/CAL9PgS20P7Ly3%2BXJTDp%2B0jEr9igB8kgVO3-YPfBT5VJhoJAUyw%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Paul Boniol

unread,
May 28, 2023, 10:17:26 AM5/28/23
to NLUG
Funny you should mention rsync. That's what I'm using to copy recent files.

You have to run root (sudo) to so some things (like preserve user/group/mtime). And in my case, to not get nagged about not being able to change user/group it needs user map and group map parameters. (Shouldn't be necessary going to ext4.)

What I ended up choosing was
sudo rsync -avc --usermap=*:paul --groupmap=*:paul source-dir dest-dir

Obviously do n for trial run till you're sure.

The checksum option obviously takes quite a while for it to start, but not choosing checksum, rsync wanted to copy every file, regardless. I'm guessing some difference in mtime storage? Idk. The user and group mapping were the last thing I set so possible it was something with that.

---Paul.

Paul Boniol

unread,
May 28, 2023, 10:25:14 AM5/28/23
to NLUG
P.S. If you're willing to ignore matching mtime, there is a --size-only parameter.

Dan Bacus

unread,
May 28, 2023, 6:01:10 PM5/28/23
to nlug...@googlegroups.com
Hi Paul,

   I don't recall any backup utilities that would just grab the file attributes without also grabbing the data, but I do have a few thoughts on the subject.

      1)  Run:  find /starting_point -ls > save
           If you'd prefer to run it the long way:   find /starting_point -exec ls -l {} \; > save

          This will get you perms, owner, and group.  Recovery would be manual, or maybe it could be scripted out.  I prefer find over ls -lR for this, as it is one file/directory per line as it iterates through the subdirectories - no blank lines to make it look pretty.

      2)  Also remember that chown, chgrp, and chmod all have a -R option, for recursive.  If a good chunk of the files and directories are the same, that would help get the bulk of them done, and then you'd just have to manually set the remaining.

   Hope this helps.

Dan

--
--
You received this message because you are subscribed to the Google Groups "NLUG" group.
To post to this group, send email to nlug...@googlegroups.com
To unsubscribe from this group, send email to nlug-talk+...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/nlug-talk?hl=en

---
You received this message because you are subscribed to the Google Groups "NLUG" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nlug-talk+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nlug-talk/CAL9PgS20P7Ly3%2BXJTDp%2B0jEr9igB8kgVO3-YPfBT5VJhoJAUyw%40mail.gmail.com.

Dan Bacus

unread,
May 28, 2023, 6:01:17 PM5/28/23
to nlug...@googlegroups.com
Something else I'd like to add since the discussion moved this way a bit...

If you use the cp -rp command for a recursive copy, the owner and group are not preserved as they are set on the target side to the user who is doing the copy.  Also, mtime is set to "now" on the target side.

However, if you want to preserve owner, group, perms, and mtime on a copy you can do the following as root:

cd /source
find . -depth -print | cpio -pdm /target

1) You must hand cpio the filenames to be copied using a relative path (.)
2) For decades find did not have a default action of -print, so I still put it there out of habit.
3) You need -depth so that find starts at the bottom of the filesystem tree and works its way back up.  This makes it so that cpio will set mtimes on the directories back to what they had in /source
4) The -p option on cpio is pass-through.  It does not build a backup/archive file, it does a copy.  The -d option is to make sub-directories as needed, and -m maintains mtimes from source to target.

I used this a lot when moving directories in / into their own new filesystems after a system had been installed, say /opt, again as root:

mount /dev/whatever /mnt
cd /opt
find . -depth -print | cpio -pdm /mnt
cd /
du -sk /opt  /mnt             <==  /mnt should be slightly larger than /opt due to the /mnt/lost+found directory that was not in /opt since it is a part of /
rm -rf /opt/*                     <== remove everything inside of /opt to free up space in the / filesystem, but leave /opt the directory for the mount point
umount /mnt
mount /dev/whatever /opt
vi /etc/fstab                    <== or /etc/vfstab, or /etc/filesystem depending upon OS; and add an entry to mount /opt at boot time.

Dan

--
--
You received this message because you are subscribed to the Google Groups "NLUG" group.
To post to this group, send email to nlug...@googlegroups.com
To unsubscribe from this group, send email to nlug-talk+...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/nlug-talk?hl=en

---
You received this message because you are subscribed to the Google Groups "NLUG" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nlug-talk+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nlug-talk/CAL9PgS1x3tG5%3DwBYi0%2BAg88mVXVX3q9pzb-Czyqw0SATBxU7gQ%40mail.gmail.com.

Paul Boniol

unread,
May 30, 2023, 3:00:11 AM5/30/23
to NLUG
FYI: Didn't find a quick solution, so I did a find command executing ls and saving to a file, just to have it. The more I looked, things were not all "best" as programs and file systems changed over the years.

So, I'm largely done doing recursive chown, and find executing chmods.

---Paul.

Reply all
Reply to author
Forward
0 new messages