Avatar of bkreynolds48
bkreynolds48 asked on

Linux using TAR to backup to tape with variables in script

I am trying to get my backup script to work with tar on a linux system.
The varialble FILES is where I put a list of files to be backed up but this is not working.
================
here is the ouput produced by the script
================================
 BACKUP started at Wed May 28 10:10:44 CDT 2008
Where am I?
/root/logs
tar: Removing leading `/' from member names
/root/logs/files
 BACKUP finished at Wed May 28 10:10:49 CDT 2008
==========================================
here is the script
==========================================
#!/bin/ksh
# set +xv
# File: /bkup.sh
#######################################################################
#
#
DATE=`date +%m%d%y`
BULOG=/root/logs/bkup_$DATE.log
FILES=/root/logs/files
#
########### Start of the script. ######################################
echo " BACKUP started at `date`" > $BULOG 2>&1
echo "Where am I?" >>$BULOG
pwd >>$BULOG
find /var/subversion -print |grep -v *.dump |grep -v *.tar > $FILES
find /usr/nagios -print >>$FILES
#
mt -f /dev/st0 rewind
#
tar -cvf /dev/nst0 $FILES >> $BULOG 2>&1
#
mt -f /dev/st0 rewind
#
echo " BACKUP finished at `date`" >> $BULOG 2>&1
===================================================
Linux

Avatar of undefined
Last Comment
omarfarid

8/22/2022 - Mon
omarfarid

this command

tar -cvf /dev/nst0 $FILES

will take backup of single file /root/logs/file

change command to

tar -cvf /dev/nst0 `cat $FILES`
ASKER
bkreynolds48

I made that change and here is the log file output..............

BACKUP started at Wed May 28 10:44:57 CDT 2008
Where am I?
/root/logs
/root/logs/bkup.sh[24]: tar: /usr/bin/tar: cannot execute [Argument list too long]
 BACKUP finished at Wed May 28 10:44:57 CDT 2008
ASKER CERTIFIED SOLUTION
omarfarid

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
bkreynolds48

omarfarid, thanks - that worked!:)
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ASKER
bkreynolds48

It looks like the tar command is NOT really using the $FILES ????
====Here is the tar command running on the system
tar -cvf /dev/nst0 --files-from=/root/logs/files
==== here is what is in $FILES
head files
/var/subversion
/var/subversion/brad
/var/subversion/brad/conf
/var/subversion/brad/conf/svnserve.conf
/var/subversion/brad/conf/passwd
/var/subversion/brad/conf/authz
/var/subversion/brad/dav
/var/subversion/brad/format
/var/subversion/brad/db
/var/subversion/brad/db/uuid
====here is the tar log file
head *.log
 BACKUP started at Wed May 28 12:25:12 CDT 2008
Where am I?
/root/logs
tar: Removing leading `/' from member names
/var/subversion/
/var/subversion/tim.dump.bak
/var/subversion/oracle.dump
/var/subversion/brad/
/var/subversion/brad/conf/
/var/subversion/brad/conf/svnserve.conf



omarfarid

it is working perfect with me:

[omar@F8 ~]$ tar cvf /tmp/f.tar --files-from=/tmp/file
tar: Removing leading `/' from member names
/etc/hosts
/etc/passwd
/etc/group
/bin/ls
/bin/tar
[omar@F8 ~]$ cat /tmp/file
/etc/hosts
/etc/passwd
/etc/group
/bin/ls
/bin/tar
[omar@F8 ~]$ tar tvf /tmp/f.tar
-rw-r--r-- root/root       188 2008-03-07 16:59 etc/hosts
-rw-r--r-- root/root      1950 2028-12-05 20:43 etc/passwd
-rw-r--r-- root/root       839 2028-12-05 20:42 etc/group
-rwxr-xr-x root/root     99564 2008-03-25 22:04 bin/ls
-rwxr-xr-x root/root    272456 2008-02-12 18:00 bin/tar


can you run

tar tvf /dev/nst0

and compare with your files to be backed up?