Results 1 to 10 of 11
Hi All,
I dont know if this question as been asked before I am doing a backup script for my webserver and I dont want it backing up a folder.
...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 05-18-2006 #1Just Joined!
- Join Date
- Apr 2006
- Location
- UK, Devon
- Posts
- 41
Tar and expecting Folders
Hi All,
I dont know if this question as been asked before I am doing a backup script for my webserver and I dont want it backing up a folder.
I have been told the command is
tar cvf testing.tar /home/httpd/www/* --exclude /home/httpd/www/testingsite/*
But it don't seem to be missing the exclude so can any one help me please
I am running Suse 9.3 Pro. GNU Tar
Luke.
- 05-18-2006 #2
Looking at the man page for tar, it seems the --exclude option is only for a single file rather than a folder. The only way i can see to do this is to put the list of files in that folder into a file
then use that file with the --exclude-from (or -X) option like:Code:ls /home/httpd/www/testingsite > testing-excludes
someone feel free to prove me wrong on this, but that's a simpler way of doing it that i can see, this can also be put into one line on the command line using && to seperate the commands eg:Code:tar cvf testing.tar /home/httpd/www/* -X testing-excludes
Code:ls /home/httpd/www/testingsite > testing-excludes && tar cvf testing.tar /home/httpd/www/* -X testing-excludes
"I am not an alcoholic, alcoholics go to meetings"
Registered Linux user = #372327
- 05-18-2006 #3Just Joined!
- Join Date
- Apr 2006
- Location
- UK, Devon
- Posts
- 41
Thanks for that dude I will give it ago
Little problem I have folders in that which still get backed up any more ideas.
- 05-18-2006 #4
oops, you will probs wanna do a recursive list to pick up all the files...
note: -R addedCode:ls -R /home/httpd/www/testingsite > testing-excludes && tar cvf testing.tar /home/httpd/www/* -X testing-excludes
"I am not an alcoholic, alcoholics go to meetings"
Registered Linux user = #372327
- 05-18-2006 #5Just Joined!
- Join Date
- Apr 2006
- Location
- UK, Devon
- Posts
- 41
Again Thanks for the help dude. Will give it ago.
- 05-18-2006 #6Just Joined!
- Join Date
- Apr 2006
- Location
- UK, Devon
- Posts
- 41
Nope don't work dude I am stuck now as my boss needs a backup.
- 05-18-2006 #7
Can u give an example of a few files that are still being included in the backup? with Full paths
"I am not an alcoholic, alcoholics go to meetings"
Registered Linux user = #372327
- 05-18-2006 #8Just Joined!
- Join Date
- Apr 2006
- Location
- UK, Devon
- Posts
- 41
Right heres the full thing
I need to back-up
/srv/www/
the directory that needs to be skiped is
/srv/www/htdocs/mod/object/repository
The folder that needs to be skiped contants lots of subfolders and then subfolders in them. With files in.
Does this help. If not I will past a full directory listing.
- 05-18-2006 #9
does everything further down than /srv/www/htdocs/mod/object/repository need skipping, including sub-folders contents, and sub-sub folders contents? If so, maybe using find would be a bit easier since ls dowsn't seem to be finding all the files...
Failing that, I'm out of ideas apart from temporarily moving the files out of /srv/www, maybe move the repository directory into /srv, then backup the www dir, then move the repository directory back to the right place. That's the long way round it, I will continue looking into this for you though, just had another idea!Code:find /srv/www/htdocs/mod/object/repository -iname '*' > testing-excludes && tar cvf testing.tar /srv/www/* -X testing-excludes
EDIT: Just looked at the tar man page, there's a --delete option. What you could do is tar the whole lot up, then delete the repositories directory from the tarball.
From reading something like:though personally, i would try this with some test files, or backup the whole /srv/www directory first incase it does mess it up.Code:tar cvf testing.tar /srv/www/* && tar --delete testing.tar /srv/www/htdocs/mod/object/repository/*
"I am not an alcoholic, alcoholics go to meetings"
Registered Linux user = #372327
- 05-18-2006 #10Just Joined!
- Join Date
- Apr 2006
- Location
- UK, Devon
- Posts
- 41
Thanks dude.
and yeah any thing after the repository directory dont need backing up and I will try the new ideas.


Reply With Quote
