My OS: Ubuntu Server 18.04 "Bionic Beaver" LTS (64bits)
#!/bin/bash
#
### Ustawienia - sciezki do plik�w ###
DIRS="/home/ts/ /home/mc/"
BACKUP=/home/backup.$$
NOW=$(date +"%d-%m-%Y")
DELDATE=$(date -d "-7 days" +"%d-%m-%Y")
DAY=$(date +"%a")
#
### MySQL ###
MUSER="hiden"
MPASS="hiden"
MHOST="localhost"
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
GZIP="$(which gzip)"
#
### FTP ###
FTPD="Backup"
FTPU="hiden"
FTPP="hiden"
FTPS="hiden"
NCFTP="$(which ncftpput)"
#
### Start Backup for file system ###
[ ! -d $BACKUP ] && mkdir -p $BACKUP || :
#
FTPD=$FTPD
FILE="files-$NOW.zip"
zip -r $BACKUP/$FILE $DIRS
### Start MySQL Backup ###
# Get all databases name
DBS='$($MYSQL -u $MUSER -h $MHOST -p$MPASS -Bse "show databases")'
for db in '$DBS'
do
FILE=$BACKUP/mysql-$db.$NOW-$(date +"%T").gz
$MYSQLDUMP -u $MUSER -h $MHOST -p$MPASS $db | $GZIP -9 > $FILE
done
#
### Dump backup using FTP ###
#Start FTP backup using ncftp
ncftp -u"$FTPU" -p"$FTPP" $FTPS<<EOF
cd $FTPD
rm -r $DELDATE/*
rm -r $DELDATE
cd
mkdir $FTPD
mkdir $FTPD/$NOW
cd $FTPD/$NOW
lcd $BACKUP
mput *
quit
EOF
#
### Find out if ftp backup failed or not ###
rm -rf $BACKUP
When I run it I get error:
zip warning: name not matched: /home/mc/
but when I will modified $DIRS to: DIRS="/home/ts/ /home/mc/ /home/mc2/" I will get that same error but with mc2, because the program found this directory: /home/mc/
and next get this error
./backup.sh: 35: ./backup.sh: Syntax error: word unexpected (expecting "do")
Thanks for found quotation marks I don't know why this script working properly on: ubuntu server 17.10 artful aardvark but on 18.04 "Bionic Beaver" have problem...
And when I leave an empty line without a comment, I get this error:
root@mines:~# sh ./backup.sh
: not found: 2: ./backup.sh:
Can you check that the script has no funny characters in it?
cat -vet backup.sh
Can you also check that every command you use (mysql, mysqldump, ncftpput etc) are installed? It may be that if this is a new installation not all the utilities you use in this script may be installed by default.