LINUX - Need help with tar command

Discussion in 'Site & Server Administration' started by traian1, Dec 21, 2009.

  1. #1
    Hi,
    I need some help with a tar command in linux.

    I need to backup the contents of a folder, but also need to exclude some directories.

    My directory structure.

    home
    >files
    >names
    >recordings
    >laps
    >>reside
    >>receipe
    >>koling
    >hello

    I need to tar the whole home directory, but exclude all the whole "recordings" directory, and also in the "lap" directory, I only need the files in it, but not the directories. Note that the directories in the laps folder are auto-generated and have different names, and the amounts of subdirectories are random aswell.

    What's the most efficient way of doing this with a tar command?

    Thank you
     
    traian1, Dec 21, 2009 IP
  2. sahabcse

    sahabcse Well-Known Member

    Messages:
    272
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    140
    #2
    tar cvpzf backup.tgz --exclude=/lost+found --exclude=/recordings /home

    better you include "lap" directory
     
    sahabcse, Dec 23, 2009 IP