1827871 Members
1160 Online
109969 Solutions
New Discussion

Simple TAR command

 
admin1979
Super Advisor

Simple TAR command


Just a simple question about tar.

We have a filesystem,

/
/boot
/usr/users


In order to take the backup of these filesystems, we connected USB drive and mounted under /usb.

Then to get the root backup , I used

tar -cvf root.tar /

And it showed as after few minutes it was taking the backup of /usb contents as well.

Oooops something not expected. Is it a normal behaviour , or we are missing some option here?
How do we avoid this.
In short how do we take the complete filesystem backup excluding specific filesystems?

You guys must be running backup scripts for so many years ... then how did you manage to handle this situation.
Please suggest.


Thanx,
admin
4 REPLIES 4
Michal Kapalka (mikap)
Honored Contributor

Re: Simple TAR command

hi,

you should use --exclude=usb,

and don;t forget use -p ( for the file/directory ownership )

mikap
Michal Kapalka (mikap)
Honored Contributor

Re: Simple TAR command

hi,

if the usb disk is mounted as /usb

and you in the root /

them

tar cvfp /usb/file+of_backup.tar --directory / --exclude=usb

mikap
admin1979
Super Advisor

Re: Simple TAR command

Ok thanx. Let me try it out and get back here.
Goran Koruga
Honored Contributor

Re: Simple TAR command

Hi.

This is expected.

or better yet, use the "--one-file-system" option with tar.

Goran