LinHES Forums
http://forum.linhes.org/

tar question - backing up a dir and ignore symlinks?
http://forum.linhes.org/viewtopic.php?f=5&t=19461
Page 1 of 1

Author:  graysky [ Thu Jan 22, 2009 4:06 pm ]
Post subject:  tar question - backing up a dir and ignore symlinks?

Any tar gurus out there? I've been using tar to backup my system and I'm wondering what switch I need to through into my line to have tar IGNORE my symlinks. Anyone?

Here is the syntax I've been using, but again, it will follow any symlinks which I do NOT want :)

Thanks!

Code:
tar zcvfp backup-system.tar.gz /etc /boot /root /home

Author:  slowtolearn [ Thu Jan 22, 2009 6:19 pm ]
Post subject: 

Not sure what you are really after here, as I believe tar normally doesn't follow symlinks, but see the -h option here if you are trying to backup the files/directories your symlinks are pointing to and not the actual link.

If you are trying to ignore symlinks altogether (as in no reference to them or the files/directories they point to whatsoever), you may want to use find with the -H or multiple -t, -e -d options in conjunction with cpio. man find for more information.

Author:  graysky [ Thu Jan 22, 2009 7:23 pm ]
Post subject: 

I think the -h switch will do the trick. Thanks. BTW, the output of a simple, 'man tar' wasn't that useful. There is a great online manual for tar over at gno.org. MUCH more descriptive.

Author:  alien [ Fri Jan 23, 2009 3:29 am ]
Post subject: 

Actually, the -h will follow symlinks, which I don't think is what you want. Without the -h, the symlinks will be saved, not the files or dir they point to.

When you extract the files, are you sure it isn't a symlink that is extracted? It will look exactly like the original. Example:

Code:
allen@violet:~$ ls -al etc/lircd.conf
lrwxrwxrwx 1 allen allen 20 Jan 23 09:09 etc/lircd.conf -> /etc/lirc/lircd.conf
allen@violet:~$


To get it to completely ignore symlinks will probably require the use of "find".

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/