Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
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.
  1. #1
    Just 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.

  2. #2
    Linux Guru sdousley's Avatar
    Join Date
    Feb 2004
    Posts
    1,790
    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
    Code:
    ls /home/httpd/www/testingsite > testing-excludes
    then use that file with the --exclude-from (or -X) option like:
    Code:
    tar cvf testing.tar /home/httpd/www/* -X 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:
    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

  3. #3
    Just 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.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru sdousley's Avatar
    Join Date
    Feb 2004
    Posts
    1,790
    oops, you will probs wanna do a recursive list to pick up all the files...

    Code:
    ls -R /home/httpd/www/testingsite > testing-excludes && tar cvf testing.tar /home/httpd/www/* -X testing-excludes
    note: -R added
    "I am not an alcoholic, alcoholics go to meetings"
    Registered Linux user = #372327

  6. #5
    Just Joined!
    Join Date
    Apr 2006
    Location
    UK, Devon
    Posts
    41
    Again Thanks for the help dude. Will give it ago.

  7. #6
    Just 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.

  8. #7
    Linux Guru sdousley's Avatar
    Join Date
    Feb 2004
    Posts
    1,790
    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

  9. #8
    Just 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.

  10. #9
    Linux Guru sdousley's Avatar
    Join Date
    Feb 2004
    Posts
    1,790
    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...

    Code:
    find /srv/www/htdocs/mod/object/repository -iname '*' > testing-excludes && tar cvf testing.tar /srv/www/* -X testing-excludes
    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!

    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:
    Code:
    tar cvf testing.tar /srv/www/* && tar --delete testing.tar /srv/www/htdocs/mod/object/repository/*
    though personally, i would try this with some test files, or backup the whole /srv/www directory first incase it does mess it up.
    "I am not an alcoholic, alcoholics go to meetings"
    Registered Linux user = #372327

  11. #10
    Just 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.

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •