[solved] Tar is not extracting all content of the archive

It is weird i went thru the manual and was searching and trying, but this is what happen on Raspbian 10 with tar v.1.30:

list contents of the dir. i want to archive:
ls -lht /home/hts/.hts/tvheadend

total 1.7M
-rw------- 1 hts video 1.6M Mar 24 15:21 epgdb.v2
drwx------ 2 hts video 4.0K Mar 24 13:02 service_mapper
-rw------- 1 hts video 1.2K Mar 19 15:47 config
-rw------- 1 hts hts 41 Jan 28 19:55 superuser
drwx------ 2 hts video 4.0K Dec 18 12:47 accesscontrol
drwx------ 3 hts video 4.0K Dec 17 12:56 epggrab
drwx------ 2 hts video 4.0K Dec 17 12:52 passwd
drwx------ 5 hts video 4.0K Dec 10 17:17 input
drwx------ 4 hts video 4.0K Nov 26 23:38 channel
drwx------ 2 hts video 4.0K Nov 26 23:09 bouquet
drwx------ 3 hts video 4.0K Nov 26 23:09 dvr
drwx------ 2 hts video 4.0K Nov 26 23:09 profile

create archive:

tar -pcf /home/hts/.hts/tvheadend_backup.tar -C /home/hts/.hts/ tvheadend

remove original dir.

extract archive:

tar -pxf /home/hts/.hts/tvheadend_backup.tar

list dir. contents:
ls -lht /home/hts/.hts/tvheadend

total 20K
drwx------ 2 hts video 4.0K Mar 24 16:02 bouquet
drwx------ 3 hts video 4.0K Mar 24 16:02 dvr
drwx------ 3 hts video 4.0K Mar 24 16:02 input
drwx------ 2 hts video 4.0K Mar 24 16:02 profile
-rw------- 1 hts video 1.2K Mar 24 16:02 config

you can see that not all items was extracted. And the archive contains missing items likely:
tar --list -f /home/hts/.hts/tvheadend_backup.tar|grep service_mapper

tvheadend/service_mapper/
tvheadend/service_mapper/config

i tried to assign -vv to the tar extract command, and it shown like extracting was done:

drwx------ hts/video 0 2020-03-24 13:02 tvheadend/service_mapper/
-rw------- hts/video 146 2020-03-24 13:02 tvheadend/service_mapper/config
yet the item is not in the directory as shown above.

Avoid creating tar in same dir. So try:

tar -pcf /home/hts/tvheadend_backup.tar /home/hts/.hts/tvheadend/

Thanks for the reply. What worked was to define custom save path like this:
tar -cf abc.tar -C /path/to/ directory
rm -rf /path/to/directory
tar -xf abc.tar -C /path/to/
(note the spaces)

UPDATE: archiving command may be without -C but the extracting seems to require -C, else it will extract absolute path into current directory


Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki