I'm sure this must be an obvious error but I am stumped. The shell script below generates a database dump and gzips it successfully but aws cli gives error:
warning: Skipping file /home/bar/dbsnapshots/foo-12-11-2016.sql.gz/. File does not exist.
I see the trailing slash in this error but do not understand why it is displayed or if, in fact, aws is looking for a directory named foo-12-11-2016.sql.gz for some reason?
ls shows the file as expected.
vi /home/bar/dbsnapshots/foo-12-11-2016.sql.gz opens the gz file successfully.
I have tried the aws command with and without quotes around the path, same error. I have tried the aws command by itself outside the shell script from command line, same error. eg
/home/bar/bin/aws s3 sync "/home/bar/dbsnapshots/foo-12-11-2016.sql.gz" s3://foo
The AWS CLI is locally installed by my user on this shared server in /home/bar/awscli-bundle and is configured and was able to create a bucket on S3. Verified via AWS browser GUI.
#!/bin/bash
TODAY=`/bin/date +"%-m-%-d-%Y"`
BU_DIR=/home/bar/dbsnapshots
LOCALFILE=$BU_DIR/foo-${TODAY}.sql
EXCLUDED_TABLES=(
membersBackupV2
transactionReferer
transpages
)
IGNORED_TABLES_STRING=''
for TABLE in "${EXCLUDED_TABLES[@]}"
do :
IGNORED_TABLES_STRING+=" --ignore-table=bar_membership.${TABLE}"
done
mysqldump --defaults-extra-file="${BU_DIR}/.my.cnf" --all-databases ${IGNORED_TABLES_STRING} > ${LOCALFILE}
/bin/gzip ${LOCALFILE}
/home/bar/bin/aws s3 sync ${LOCALFILE}.gz s3://foo