excluding directories in harddrive backup using tar

I want to backup my debian installation using tar but excluding certain directories like /proc and /dev. Also do I need to put the backup file in /tmp and exclude /tmp so that tar won't try to include the file it's creating?

I've tried numerous ways with no success.

Thanks.

0

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

excluding directories in

Did you try the --exclude or --exclude-from options?

If you need to store the backup file temporarily, then /tmp is the obvious place. You wouldn't want to backup /tmp anyway since by definition it's only for temporary files.

$world=~s/war/peace/g;

excluding directories in harddrive backup using tar

Yes but I'm not sure the syntax was correct. I tried

tar -cvfj backup.tbz / --exclude=/tmp /proc /dev

and

tar -cvfj backup.tbz / --exclude-from=/tmp /proc /dev

and got error messages like "no such file or directory" "/proc is a directory" "can not stat"

excluding directories in harddrive backup using tar

The path goes last, and you need to specify --exclude for each file or directory:


tar -cvfj backup.tbz --exclude=/tmp \
--exclude=/proc --exclude=/dev /

The --exclude-from=FILE option allows for listing the exclusions in a file named FILE if you get tired of typing all those excludes :-).

Syndicate content