PDA

View Full Version : What's wrong with this tar command?



glennzo
24th March 2012, 03:53 PM
Run from a script

tar -czvf $BACKUP_DIR/$BACKUP_NAME *
I get the following greeting:


tar: You may not specify more than one `-Acdtrux' or `--test-label' option
Try `tar --help' or `tar --usage' for more information.


In the script ...

BACKUP_DIR="/mnt/disk3/backup"
BACKUP_NAME="scripts-`date +%Y%m%d`.tar.gz"

Adunaic
24th March 2012, 03:58 PM
Nothing that I can tell. It works on mine with

I set the variables to have the same name as yours as well. Perhaps it is a file in the dir it does not like?

glennzo
24th March 2012, 04:01 PM
Dunno. Baffling the heck out of me. I could have sworn that it worked fine earlier today. Now I changed -czvf to -zvcf and it works. That can't be the trouble, could it?

Error messages are so cryptic sometimes, aren't they?

Here's the complete script as it stands now.


#!/bin/bash
# - bup.sh
# - A script to backup scripts
#
# - Glenn A. Johnson - November 27, 2011
# - Last edited March 24, 2012
#
BACKUP_DIR="/mnt/disk3/backup"
BACKUP_NAME="scripts-`date +%Y%m%d`.tar.gz"
#
# - Must be root user to run script
#
if [[ $EUID -ne 0 ]] ; then
echo "You need to run this script with root permissions"
exit 1
fi
#
# - Source my include files
. includes
. scolors
#
# - Run the backup archiving all files in the current folder
#
tar -zvcf $BACKUP_DIR/$BACKUP_NAME *
#
# - Finish up and exit
echo -e ${txtgrn}"Backup file ${txtred}$BACKUP_NAME ${txtgrn}created.\nScript run completed."${txtrst}
exit 0