you can use getfacl
and setfacl
to backup/restore the permissions / ownership of files when copying between ntfs and other filesystems on linux:
to backup:
cp -rv /home /mnt/ntfs_vol
getfacl -R /home | xz -9 > /mnt/ntfs_vol/home_permissions.txt.xz
to restore:
cp -rv /mnt/ntfs_vol/home /
setfacl --restore <(xzcat /mnt/ntfs_vol/home_permissions.txt.xz)
EDIT:
Someone mentioned in a comment earlier the different between formal and informal backups / verification, and you can substitute rsync
for cp
:
TS=$(date '+%Y%m%d%H%M%s') ; rsync -avv /home \
/mnt/ntfs_vol \
--log-file="/mnt/ntfs_vol/rsync.${TS}.log" && \
getfacl -R /home \
| xz -9 > "/mnt/ntfs_vol/home_permissions.${TS}.txt.xz"
references:
https://superuser.com/questions/1002074/linux-command-line-to-create-a-log-file-for-rsync
Back up and restore file permissions
if you require more formal verification than that, then you could also produce a manifest of cryptographic hashes:
apt install parallel
TZ=$(date '+%Y%m%d%H%M%s') ; find /home
-type f | parallel sha256sum {}
> "/mnt/ntfs_vol/backup.${TZ}.manifest"
and to verify:
sha256sum --quiet -c /mnt/ntfs_vol/backup.2023122707571703692656.manifest
If you don't like tar, because of the name, or whatever reason but can appreciate having an archival format there is another fairly common alternative:
find /home | cpio -vo > /mnt/ntfs_vol/archive.cpio
and if you inspect the contents of this format:
find /usr/include/ | cpio -o | hexdump -C | head -n 20
00000000 c7 71 1d 00 9c 09 ed 41 00 00 00 00 01 00 00 00 |.q.....A........|
00000010 83 65 9c 05 0e 00 00 00 00 00 2f 75 73 72 2f 69 |.e......../usr/i|
00000020 6e 63 6c 75 64 65 2f 00 c7 71 1d 00 f9 47 ed 41 |nclude/..q...G.A|
00000030 00 00 00 00 01 00 00 00 92 64 2a 63 16 00 00 00 |.........d*c....|
00000040 00 00 2f 75 73 72 2f 69 6e 63 6c 75 64 65 2f 69 |../usr/include/i|
00000050 70 72 6f 75 74 65 32 00 c7 71 1d 00 f2 d6 a4 81 |proute2..q......|
00000060 00 00 00 00 01 00 00 00 6b 64 f8 6b 20 00 00 00 |........kd.k ...|
00000070 f7 04 2f 75 73 72 2f 69 6e 63 6c 75 64 65 2f 69 |../usr/include/i|
00000080 70 72 6f 75 74 65 32 2f 62 70 66 5f 65 6c 66 2e |proute2/bpf_elf.|
00000090 68 00 2f 2a 20 53 50 44 58 2d 4c 69 63 65 6e 73 |h./* SPDX-Licens|
000000a0 65 2d 49 64 65 6e 74 69 66 69 65 72 3a 20 47 50 |e-Identifier: GP|
000000b0 4c 2d 32 2e 30 20 2a 2f 0a 23 69 66 6e 64 65 66 |L-2.0 */.#ifndef|
000000c0 20 5f 5f 42 50 46 5f 45 4c 46 5f 5f 0a 23 64 65 | __BPF_ELF__.#de|
000000d0 66 69 6e 65 20 5f 5f 42 50 46 5f 45 4c 46 5f 5f |fine __BPF_ELF__|
000000e0 0a 0a 23 69 6e 63 6c 75 64 65 20 3c 61 73 6d 2f |..#include <asm/|
000000f0 74 79 70 65 73 2e 68 3e 0a 0a 2f 2a 20 4e 6f 74 |types.h>../* Not|
00000100 65 3a 0a 20 2a 0a 20 2a 20 42 65 6c 6f 77 20 45 |e:. *. * Below E|
00000110 4c 46 20 73 65 63 74 69 6f 6e 20 6e 61 6d 65 73 |LF section names|
00000120 20 61 6e 64 20 62 70 66 5f 65 6c 66 5f 6d 61 70 | and bpf_elf_map|
00000130 20 73 74 72 75 63 74 75 72 65 20 64 65 66 69 6e | structure defin|
It's dead simple; having no programming experience whatsoever you could inevitably figure out how to unpack this format yourself and better yet it hasn't really changed in 46 years (as of 2023.)
More info:
https://en.wikipedia.org/wiki/Cpio
nice
andionice
are for assigning a CPU priority [0-19] and I/O priority [0-7] to a command, respectively. Lower numbers are higher priority in both cases.nice -n9 ionice -c 3 COMMAND
puts it at nice level 9 (lower CPU priority) and I/O priority 3 (idle).ionice
is NOT available on *BSD, and by extension it's not available in OSX. – amphetamachine Jan 11 '24 at 18:26