Issue with FTP Transfer Script for CRON

115 views Asked by At

I'm trying to get a Backup Script working for rackspace. The final part where it sends the backup to a server isnt working.

#!/bin/sh

#Set information specific to your site
webroot="/mnt/stor08-wc1-ord1/666666/www.mysite.com/"
db_host="mysql51-900.wc1.ord1.stabletransit.com"
db_user="666666_backup"
db_password="PassBackup2015"
db_name="666666_wealth"

#Set the date and name for the backup files
date=`date '+%F-%H-%M'`
backupname="backup.$date.tar.gz"

#Dump the mysql database

mysqldump -h $db_host -u $db_user --password="$db_password" $db_name > $webroot/db_backup.sql

#Backup Site
tar -czpvf $webroot/sitebackup.tar.gz $webroot/web/content/

#Compress DB and Site backup into one file
tar --exclude 'sitebackup' --remove-files -czpvf $webroot/$backupname $webroot/sitebackup.tar.gz $webroot/db_backup.sql

HOST='172.0.0.1'
USER='FILESERV\ftp'
PASSWD='PassBackup2015!'

ftp $HOST <<END_SCRIPT
user $USER $PASSWD
cd $webroot
put $backupname
quit
END_SCRIPT

exit 0
1

There are 1 answers

0
paxdiablo On BEST ANSWER

You may need to use ftp -n to prevent auto-login from occurring. Using auto-login with the user command often causes problems.

In other words, something like:

ftp -n $HOST <<END_SCRIPT
user $USER $PASSWD
cd $webroot
put $backupname
quit
END_SCRIPT