Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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!
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.
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.
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!
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.
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.
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".
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.