Results 1 to 6 of 6

Thread: tar seperate gzip/tar files into one tar file with one command

  1. #1
    Join Date
    May 2010
    Beans
    10

    tar seperate gzip/tar files into one tar file with one command

    I'm running out of room on the drives and can no longer do separate
    tar/gzip files before combining all gzip/tar files into one tar file.

    Is it possible to pipe a separate gzip/tar straight into a combined tar file ?

    Currently:
    #!/bin/sh
    fsFilePath="/var/backups/"
    fsFileName="WWWBackup.tar.gz"
    fsFileLoc="${fsFilePath}${fsFileName}"
    pg_dump --blobs DB1 | gzip -c > ${fsFilePath}DB1Dump.out.gz
    pg_dump --blobs DB2 | gzip -c > ${fsFilePath}DB2Dump.out.gz
    pg_dump --blobs DB3 | gzip -c > ${fsFilePath}DB3Dump.out.gz

    tar -czpf ${fsFilePath}www.tar.gz -C / var/www
    tar -czpf ${fsFilePath}apache2.tar.gz -C / etc/apache2

    fsFilePathRemoveFirstFwdSlash=`echo ${fsFilePath} | sed 's/^.//'`
    cd /
    tar -czpf ${fsFileLoc} ${fsFilePathRemoveFirstFwdSlash}*
    cd ${fsFilePath}

    ls ${fsFilePath}* | grep -v ${fsFileLoc} | xargs rm -f

    To something like:
    pg_dump --blobs DB1 | gzip -c DB1Dump.out.gz | tar -czpf combined.tar
    pg_dump --blobs DB2 | gzip -c DB2Dump.out.gz | tar -uzpf combined.tar
    pg_dump --blobs DB3 | gzip -c DB3Dump.out.gz | tar -uzpf combined.tar

    tar -czpf ${fsFilePath}www.tar.gz -C / var/www | tar -uzpf combined.tar
    tar -czpf ${fsFilePath}apache2.tar.gz -C / etc/apache2 | tar -uzpf combined.tar

    Thanks

  2. #2
    Join Date
    Oct 2010
    Location
    London
    Beans
    481
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: tar seperate gzip/tar files into one tar file with one command

    What's the advantage to doing this rather than just putting all the files in a tarball and compressing that (which could be done with a single tar command)?
    Please mark your thread as solved if you get a satisfactory solution to your problem.

  3. #3
    Join Date
    Feb 2008
    Location
    In my skin.
    Beans
    Hidden!
    Distro
    Xubuntu

    Re: tar seperate gzip/tar files into one tar file with one command

    Thread moved to Programming Talk.

    You have more chance of getting help here. Unsure why this was originally posted in ABS.

  4. #4
    Join Date
    Aug 2011
    Location
    47°9′S 126°43W
    Beans
    2,039
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: tar seperate gzip/tar files into one tar file with one command


  5. #5
    Join Date
    May 2010
    Beans
    10

    Re: tar seperate gzip/tar files into one tar file with one command

    The best way to describe what I was trying to do is to think of it like a bag full of bite sized mini bars.
    I didnt want to warp up the bite sized treats first and then individually put them in the bag.
    I wanted to wrap the bite sized snacks inside the bag itself thereby saving space on the harddrive.

    What I have done is to:
    - Dump/gzip all the small DB's and website directories into their own bite sized tar files.
    - tar the bite sized tar files into the one combined tar file.
    - Remove the mini tar files
    - Do a gzip/dump of the big database
    - Add it to the combined tar file
    - Remove the big DB tar file

    It will work for now however i'd like to know if its possible to wrap files into a tar and put them straight into a combined tar.

  6. #6
    Join Date
    Aug 2011
    Location
    47°9′S 126°43W
    Beans
    2,039
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: tar seperate gzip/tar files into one tar file with one command

    Use "tar -- concatenate"?

Bookmarks

Posting Permissions

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