What I'm trying to write is a shell script that will back up a website and all the MySQL DBs that support it. I found examples all over the 'net, but when I run the script in bash in a jailed SSH session, it fails. If I type the commands straight into the SSH session, they work fine.
#!/bin/sh DB1="first_db" THEDATE=$(date +"%Y-%m-%d") THEUSER=user THEDBPW=password mysqldump -u $THEDBUSER -p$THEDBPW $DB1 > dbbackup_$DB1_$THEDATE.sql tar -czf sitebackup_website_$THEDATE.tar /home/website/public_html gzip sitebackup_website_$THEDATE.tar
This script lives on the web server, so for testing purposes, I SSH into the server,
cd into the directory, and run
mysqldump isn't connecting, seeming to fail to pass the password in (it returns an error reporting 'using password: NO'). Then the tar command fails, reporting that it can't stat
/home/website/public_html with a 'no such file or directory'.
tar then reports it is exiting with error status due to previous errors.
What am I missing here?