LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-16-2009, 04:04 AM   #1
Thymox
Senior Member
 
Registered: Apr 2001
Location: Plymouth, England.
Distribution: Mostly Debian based systems
Posts: 4,368

Rep: Reputation: 63
More tar issues - listing files in a single tar from a multivolume borks


OK, after a bit of a booboo t'other weekend I figured it was time to modify the backup script and now it is failing with a tar exit status of 2. Below is a cut-down version of the backup script.

runbackup.sh:
Code:
tar \
    --files-from=$strINCLUDE \
    --exclude-from=$strEXCLUDE \
    --recursion \
    --create \
    --file $strBACKUPLOCATION/backup \
    --multi-volume \
    --tape-length $strSIZE \
    --format=gnu \
    --new-volume-script $strBACKUPLOCATION/post_tar_script.sh
post_tar_script.sh:
Code:
# Renames the "backup" file to "backup.date.count"
mv $strBACKUPLOCATION/backup $strBACKUPLOCATION/$strFILENAME

# BZip2 file, consequently renaming as backup.date.count.bz2
#bzip2 --compress --fast $strBACKUPLOCATION/$strFILENAME
#strFILENAME=$strFILENAME&".bz2"

# Find size of file and add it to textfile
strSIZEOFFILE=`ls -l $strBACKUPLOCATION/$strFILENAME | awk '{print $5}'`
echo $strSIZEOFFILE $strFILENAME >> $strBACKUPLOCATION/filesizes.list

# Create a list of files
echo $strFILENAME >> $strBACKUPLOCATION/filenames.list
echo ---------- >> $strBACKUPLOCATION/filenames.list
tar --list -f $strBACKUPLOCATION/$strFILENAME >> $strBACKUPLOCATION/filenames.list
echo ---------- >> $strBACKUPLOCATION/filenames.list

# FTP the file to FTP server
lftp -c "open $strHOST -e 'put $strFILENAME -o $strDAY/$strFILENAME' -u $strUSER,$strPASSWD"

# Remove FTPd, backed-up file
rm -f $strBACKUPLOCATION/$strFILENAME

#Try and force the parent tar to see a clean exit and continue.
exit 0
As you can see, I'm trying to create a multi-volume tar archive with each volume being $strSIZE in length. At the end of each $strSIZE volume it runs the post_tar_script.sh file. This renames the backup file appropriately, finds the size of the file and appends this to a text file (which will get mailed off), creates a list of all the files in the current volume (this is the new part), then FTPs the file off and removes the file from the filesystem.

Now, what's happening is that tar is failing with an exit status of 2. The GNU tar documentation says:
Quote:
If tar has invoked a subprocess and that subprocess exited with a nonzero exit code, tar exits with that code as well.
So, I'm guessing that the post_tar_script.sh is exiting with 2... but what's causing it? I doubt it's the mv, rm or echo commands causing the problem... which kinda leaves either the lftp or the tar. But if it is tar that causing the issue, then I'm going around in circles... tar exits with a status of 2 because the subprocess (ultimately tar) exits with a status of 2.

Help!
 
Old 09-16-2009, 10:09 PM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
Hi,

Have you got 'set -x' at the top of your script ? .. it will give you a lot more output, might make it easier to see where the problem is

cheers
 
Old 09-22-2009, 03:22 AM   #3
Thymox
Senior Member
 
Registered: Apr 2001
Location: Plymouth, England.
Distribution: Mostly Debian based systems
Posts: 4,368

Original Poster
Rep: Reputation: 63
Cheers kbp,
Would I need to put it at the top of both the main backup script and the post_tar_script.sh file, or would it carry through after having been invoked in the main backup script?
 
Old 09-23-2009, 03:07 AM   #4
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
I'm not sure .. put it in both to be sure
 
Old 09-23-2009, 07:48 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 17,873

Rep: Reputation: 2600Reputation: 2600Reputation: 2600Reputation: 2600Reputation: 2600Reputation: 2600Reputation: 2600Reputation: 2600Reputation: 2600Reputation: 2600Reputation: 2600
Actually, try

set -xv

more verbose
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
listing the contents of large tar files szim90 Linux - Software 6 04-06-2007 09:23 AM
BackUp & Restore with TAR (.tar / .tar.gz / .tar.bz2 / tar.Z) asgarcymed Linux - General 5 12-31-2006 02:53 AM
tar | ssh (tar > .tar) syntax issues EarlMosier Linux - Software 6 12-21-2006 12:28 AM
Creating multivolume archives using tar sharathksin Programming 6 03-06-2006 05:00 AM
Extracting multivolume tar Cichlid Linux - Software 3 12-21-2003 01:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration