Shell tar: Option --transform is not supported

hi
I'm dabbling with shell scripting a little and trying to get a backup script running on FreeBSD.

Code:
#!/bin/csh
NOW=$(date +"%Y-%m-%d-%H%M")
FILE="example.com.$NOW.tar"
BACKUP_DIR="/usr/home/andy/backups"
WWW_DIR="/var/www/"
DB_USER="user"
DB_PASS="pass"
DB_NAME="dbname"
DB_FILE="example.com.$NOW.sql"

WWW_TRANSFORM='s,^var/www,public_html,'
DB_TRANSFORM='s,^usr/home/andy/backups,database,'

tar -cvf $BACKUP_DIR/$FILE --transform $WWW_TRANSFORM $WWW_DIR
mysqldump -u$DB_USER -p$DB_PASS $DB_NAME > $BACKUP_DIR/$DB_FILE

tar --append --file=$BACKUP_DIR/$FILE --transform $DB_TRANSFORM $BACKUP_DIR/$DB_FILE
rm $BACKUP_DIR/$DB_FILE
gzip -9 $BACKUP_DIR/$FILE

/bin/csh backup.script
Code:
Illegal variable name.
Illegal variable name? There are several variables in my script; not the most verbose error message then.

Another angle I've tried this from is:

/usr/local/bin/bash backup.script and adjusting the shebang accordingly:
Code:
tar: Option --transform is not supported

I have the following shells on my system:
Code:
/bin/sh
/bin/csh
/bin/tcsh
/usr/local/bin/bash
/usr/local/bin/rbash

The original tutorial is from: http://theme.fm/2011/06/a-shell-script-for-a-complete-wordpress-backup-4/

Why would tar() work with --transform on Ubuntu and not on FreeBSD?


Can anyone throw me a bone?

Thanks in advance.
 
Code:
#!/bin/sh
# backup mysql databases shell script
# Usage: /home/andy/scripts/./backup.sh

DATE=$(date +%Y-%m-%d)
MYSQL=$(which mysql)
MYSQLDUMP=$(which mysqldump)
MYSQL_USER="user"
MYSQL_PASS="pass"
HOSTNAME=$(hostname)
GZIP=$(which gzip)
ARG="-u $MYSQL_USER -p$MYSQL_PASS"
DATABASES=$($MYSQL $ARG -s -e "SHOW DATABASES LIKE 'mydb';")
BACKUP_PATH="/home/andy/backups/$DATE/mysql"

! [ -d $BACKUP_PATH ] && mkdir -p $BACKUP_PATH

for DB in $DATABASES
do
  BACKUP_FILE="$BACKUP_PATH/$HOSTNAME-mysql-$DB-$DATE.sql.gz"
   $MYSQLDUMP $ARG $DB | $GZIP -9 > $BACKUP_FILE
done

The

Code:
-e "SHOW DATABASES LIKE 'mydb'"

is necessary, since it prevents mysqldump from returning the following errors:

Code:
mysqldump: Got error: 1044: Access denied for user 'user'@'localhost' to database 'information_schema' when using LOCK TABLES
mysqldump: Got error: 1142: SELECT, LOCK TABLES command denied to user 'user'@'localhost' for table 'accounts' when using LOCK TABLES

thanks
 
Back
Top