How can I repack .bz2 archive to .xz format, if I want to save datestamp of file and its chmod-chown settings?
I can use any standard tools and xz, lzma, p7zip
You need to break this into two parts
1) Convert from bz2 to xz, which billc.cn answered
2) Fix the ownership, permissions and timestamp of the xz file to match the bz2.
chown "`stat --printf '%u:%g' file.bz2`" file.xz chmod "`stat -c '%a' file.bz2`" file.xz touch -a -d "`stat -c '%x' file.bz2`" file.xz touch -m -d "`stat -c '%y' file.bz2`" file.xz
You can simply use
bzcat to remove the bzip2 compression but keep the tar format and then pipe the results into
bzcat file.tar.bz | xz > file.tar.xz
You can add your compression options to
xz as usual, but just leave out the file name so the standard input is used.