LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-01-2006, 07:09 PM   #1
morrolan
Member
 
Registered: Sep 2003
Location: Manchester UK
Posts: 264

Rep: Reputation: 30
Using TAR to backup /


Hi all,
I probably can't see the wood for the trees at the moment and I'm sure I've missed something, but I am trying to backup my / (i.e. everything) using TAR to an external HDD within a script.

I can get TAR to copy, but I can't seem to get the syntax correct when I am telling it to exclude certain dirs.

If I don't exclude the dir that the external HDD is mounted at, it will end up backing up my backup drive too.

Code:
tar -zcvpf /media/DWORKIN/ubuntu_backup-`date '+%d-%B-%Y'`.tar.gz
--exclude=/media --exclude=/proc .
Where DWORKIN is the external HDD.

Any attempt to exclude a directory fails, as when I watch the files go by (verbose output) it starts backing up /media/DWORKIN too.

It also doesn't work as --exclude=media. I've read the man page and "tar --help" but all it says it that
Quote:
--exclude=PATTERN .............exclude files, given as a PATTERN
What it doesn't do is explain what the pattern of PATTERN is!

Also, googling didn't help in this instance.

Many thanks in advance,

Last edited by morrolan; 01-01-2006 at 07:10 PM.
 
Old 01-01-2006, 08:03 PM   #2
jglen490
Member
 
Registered: Apr 2002
Location: The next brick house on the right.
Distribution: Kubuntu 18.04, Bodhi 5.0
Posts: 691

Rep: Reputation: 45
What you have right now for your exclude phrase is:
Quote:
--exclude=/media --exclude=/proc
I'm thinking that the file name pattern should be:
Quote:
--exclude=/media/* --exclude=/proc/*
While it's true that a directory is sort of a file, the actual files that the PATTERN looks for is files within a directory. I think that by adding something to indicate files, all in this case, within a directory that are to be excluded, you should have better luck.
 
Old 01-01-2006, 09:42 PM   #3
markir
LQ Newbie
 
Registered: Jan 2003
Posts: 1

Rep: Reputation: 0
Strange - works for me using tar 1.15.1 (simple test example):

$ cd /tmp/testdir
$ ls
dir1 dir2 dir3
$ tar -zcvpf dir3/dirs.tar.gz --exclude=dir2 --exclude=dir3 .
./
./dir1/
./dir1/file0
./dir1/file1
./dir1/file2
./dir1/file3
./dir1/file4

Are you sure that your /media/DWORKIN is not symlinked from somewhere else under / ?

regards

Mark
 
Old 01-02-2006, 12:09 AM   #4
jrdioko
Member
 
Registered: Oct 2002
Distribution: Debian 6.0.2 (squeeze)
Posts: 944

Rep: Reputation: 30
Not to change the subject, but dar works great for that kind of thing. The settings seem very user-friendly and I've been using it successfully for a while now. Anyway, tar should work fine, but dar seems to be a better system for major system-wide backups like that.
 
Old 01-02-2006, 03:08 AM   #5
grishnak
LQ Newbie
 
Registered: Jul 2004
Location: Australia
Distribution: Kubuntu 5.10
Posts: 3

Rep: Reputation: 0
I have been using ESR backup quite sucessfully for backup of 4 computers to a remote HDD. It is very easy to setup and my be what your looking for. Works for one or many computers!

www.shawnscott.net/esr/

Last edited by grishnak; 01-02-2006 at 03:14 AM.
 
Old 01-02-2006, 03:14 AM   #6
alizard
Member
 
Registered: Jan 2003
Posts: 56

Rep: Reputation: 15
My advice is don't bother with tar.

Use rsync if you're simply mirroring a drive, and dar as your solution if you want to back up compressed image files (BTW, this backs up files individually within a volume, so one disk error means ONE problem file, not a stack of them). I do both regularly (rsync every couple of days, dar monthly), and once I got the setup debugged, I haven't had problems.

For details, go to my article:
http://www.linuxpipeline.com/shared/...leId=171200965

In fact, my backup methods as described will even automatically back up the /boot partition. Not an issue for most people, but if you have had occasion to make changes, you'll appreciate this. I say methods because it'll walk you through both rsync to a drive mirror and dar to a stack of DVD-Rs.
 
Old 01-02-2006, 04:02 AM   #7
tlu
LQ Newbie
 
Registered: Jul 2004
Location: Berlin, Germany
Distribution: Fedora Core, RedHat, Debian
Posts: 1

Rep: Reputation: 0
You need to write '--exclude=./media/*' '--exclude=./proc/*'
because tar backs up ".", so the pathes it sees are

./
./media
./media/some_file

and so on.

I would also recommend to exclude

/dev/pts/* (pseudo terminal devices),
/dev/shm/* (shared-memory based RAM disk)
/sys/* (sysfs, a bit like /proc).

Hth,
Torsten
 
Old 01-03-2006, 02:44 PM   #8
RWallett
Member
 
Registered: Jan 2002
Location: Anchorage, AK
Distribution: Gentoo, Ubuntu and Slackware
Posts: 38

Rep: Reputation: 15
You could also create a file somewhere on your machine called "backup.excludes", which contains "/proc", "/dev", or whatever you want to exclude, and then use the flag "--exclude-from /somedir/backup.excludes". I've been successful with that syntax, even though, like you, I've never had any luck using "--exclude".
 
Old 01-04-2006, 05:03 AM   #9
morrolan
Member
 
Registered: Sep 2003
Location: Manchester UK
Posts: 264

Original Poster
Rep: Reputation: 30
I've resolved it now, it turns out I was missing the "/" to tell it to backup the root directory - I placed a / after the filename and before the excludes and it worked fine.

Many Thanks all - I will be looking into RSYNC now, but the backup was a matter of urgency and I didn't have time to look into another program in the timeframe, hence why I used TAR.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
backup: tar with the -L option help Paxmaster Linux - Software 1 11-18-2005 07:06 PM
Tar backup TheRealDeal Linux - General 7 02-08-2005 03:25 PM
Using tar for backup. TheRealDeal Linux - General 2 08-10-2004 11:46 PM
tar as backup imsajjadali Red Hat 4 02-07-2004 03:46 PM
tar: How do I backup everything !! grantm Linux - Newbie 3 07-30-2003 02:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration