How difficult is it to preserve metadata when moving a file?
yakking.branchable.com
yakking.branchable.com
Here's the whole list: http://yakking.branchable.com/tags/move/
Long ago, I assumed that backup (and move) applications are relatively simple. But it has never seemed to work out that way.
Today, back-to-back tar is rarely needed, as cp itself already has options to preserve metadata. In particular, "-a","--archive" turns all the normal features (including --recursive), making metadata-preserving backups as easy as:
cp -a $SRC $DST
which is a shorthand for cp --recursive --no-dereference \
--preserve=context,links,mode,ownership,timestamps,xattr
Just the "-a" option is enough for most simple local backups. Fancier backups are possible with cp's "--backup=numbered" and --reflink=auto features, but my favorite just-works solution for backups is rdiff-backup[1]. It preserves everything, uses rsync internally for minimal data transfer on incremental backups, and many more features. mount /dev/sdb1 /m
tar cf - . --exclude=./m --exclude=./proc --exclude=./sys | (cd /m; umask 0; tar -xf -)
mkdir /m/proc /m/sys
grub-install --root-directory=/m /dev/sdb
(except you must also adjust UUIDs in /etc/fstab)[1] https://technet.microsoft.com/en-us/library/cc961812.aspx
These things are a deep dark pit of problems and it isn't entirely unreasonable to just give up on them, but every once in awhile someone tries to do something useful with them so it's at least important to be aware that they exist.