problem with tar exclusion

Hello,
I want to do a backup of my whole system with tar to an external hard drive, mounted under /mnt.
As there are other backups on this external hd and I don't want to back them up again, I tried to exclude this hd from the backup.

I tried the exclude option of tar:
Code:
tar -cvf /mnt/backup.tar / --exclude=/mnt
as well as an external exclude file:
Code:
tar -cvf /mnt/backup.tar / -X /var/exclude
The exclude file contains:
Code:
/mnt/*

Neither of those methods worked...everything under /mnt was backed up.

Do I miss anything trivial?
I hope you can help me...

Thanks,
Nokobon
 
Try keeping the options at the front, i.e. before the target and destination declarations.
 
DutchDaemon said:
Try keeping the options at the front, i.e. before the target and destination declarations.

Thank you, DutchDaemon!

I tried
Code:
tar -cvf /mnt/backup.tar --exclude=/mnt /
...works perfectly.

Sometimes solutions are so easy. I'm a bit ashamed of starting a new thread because of this xD
 
Most BSD stuff works in predeined order:
Code:
cp -a /src /dest

Gnu stuff accepts command line in any way:
Code:
cp  /src -a /dest 
cp  /src -a /dest  -v
 
vivek said:
Most BSD stuff works in predeined order:
Code:
cp -a /src /dest

Gnu stuff accepts command line in any way:
Code:
cp  /src -a /dest 
cp  /src -a /dest  -v

Ah, thanks for that info.
But when I use tar with -f it's the reverse order...first destiny, then source.
 
That's confusing ;)

With tar -c (create an archive), -f denotes 'the file to write to', so it's the destination where you archived files will end up.

With tar -x (extract an archive), -f denotes 'the file to extract from', so it's the source where your archived files will be taken from.

What you can say, is that -f always denotes the archive.
 
Back
Top