I've written the following script to make backups of various important directories on my server, and to FTP them to another, remote server.
The first part of the script works fine (I've included it for reference - others may find it useful), but the problem is with the FTP part. The first file is uploaded absolutely fine, but after that, nothing is transferred. The output on the command line is:
Quote:
mput Nightly_Exalin_DNS_200706151937.tar.gz? mput Nightly_Exalin_MAIL_200706151937.tar.gz? mput Nightly_Exalin_MySQL_200706151937.tar.gz? mput Nightly_Exalin_Users_200706151937.tar.gz?
|
Nightly_Exalin_DNS_200706151937.tar.gz appears as it should, but none of the others!
The script:
Code:
#!/bin/bash
#CD to the backup directory, and move all the existing backups to the archive folder
cd /dir/backup/files
mv Nightly_Exalin_* archive
#Enter the archive folder, and delete all files older than two days
cd archive
find Nightly_Exalin_*.tar.gz -mtime +2 -exec rm -f {} \;
cd ../
#Compress all the important directories
tar -zcvf Nightly_Exalin_Users_`date '+%Y%m%d%H%M'`.tar.gz /home/* --exclude backupuser
tar -zcvf Nightly_Exalin_MySQL_`date '+%Y%m%d%H%M'`.tar.gz /var/lib/mysql/*
tar -zcvf Nightly_Exalin_DNS_`date '+%Y%m%d%H%M'`.tar.gz /var/named/*
tar -zcvf Nightly_Exalin_MAIL_`date '+%Y%m%d%H%M'`.tar.gz /var/spool/*
#Things work fine up to here
#FTP the backups to a remote server
ftp -n remote-server.co.uk <<EOFTP
quote user name
quote pass password
binary
cd backup
mput Nightly_Exalin_*.tar.gz
quit
EOFTP
I've also discovered that if I run the above commands manually, then the transfer is completed as expected - it is only when running it as part of the above script that the problems occur.
Thanks for any help.