LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   backup script multiple gzips into one bzip2 or gzip (https://www.linuxquestions.org/questions/linux-newbie-8/backup-script-multiple-gzips-into-one-bzip2-or-gzip-790029/)

z01krh 02-18-2010 03:35 PM

backup script multiple gzips into one bzip2 or gzip
 
OK I have a backup script basically is this

Code:

BACKUP_DIRS="/etc /boot /root /home"
BACKUP_FOLDER="/tmp/system_backup/

for DIR in ${BACKUP_DIRS}
do

# so instead of /var/www as a file name we get var.www.tar
TARBALL_FILE_NAME=`echo ${DIR} | sed 's/.\(.*\)/\1/' | sed -e 's///./g'`

  tar -czpmf ${BACKUP_FOLDER}/${TARBALL_FILE_NAME}.tar ${DIR}
  sleep 1

done

All the folders get dumped into seperate gzip files.
Now I want all the gzip files in the backup folder into one final gzip or bzip2 file. My goal for this is to get one file instead of multiple so I can scp or ftp the one file to another file share. Which would be easier to send one file than a bunch of files.

Thanks

kbp 02-18-2010 04:13 PM

How about:

Code:

BACKUP_DIRS="/etc /boot /root /home"
BACKUP_FOLDER="/tmp/system_backup/
NOW=$(date +%F-%s)

tar -czpmf ${BACKUP_FOLDER}/backup_${NOW}.tar.gz ${BACKUP_DIRS}

..?

z01krh 02-19-2010 10:22 AM

Thanks man that did the trick.


All times are GMT -5. The time now is 04:07 PM.