Score:0

Create bash script to upload backup over FTP

cn flag

im working on my own bash file to backup DB and transfer over ftp.
problem is the output is:

Could not open file for writing.

my code is:

DATE=`date +"%FT%T"`
DB_NAME="clcl"
DB_USER="clcl"
DB_PASSWORD="evfdfd"
LOCAL_BACKUP_DIR="/backup"
FILE_NAME="$DB_NAME-$DATE.sql.gz"
mysqldump -u $DB_USER  -p$DB_PASSWORD $DB_NAME | gzip  > $LOCAL_BACKUP_DIR/$FILE_NAME

ftp -n << EndFTP
open REMOTIP
user USER PASS
binary
hash
cd /
lcd /backup
put $FILE_NAME
bye
EndFTP
Michael Hampton avatar
cz flag
It seems very unlikely that you will have write permission in the root directory! Choose the correct directory.
Nimafire avatar
cn flag
change / to /mysql still get error: Could not open file for writing. all folders have 777 perm in FTP
Nimafire avatar
cn flag
I found Solution: code is fine. problem is because of file name contain : symbol so change Date to new value: DATE=`date +%Y-%m-%d-%H.%M.%S`
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.