I was attempting to create a bash script to run a backup of my Raspberry Pi to my Box account via FTP. Most of it works, but for some reason it won't convert variables to the text they stand for. When I run this script:
#!/bin/bash
FILENAME=backup-$(date +%Y-%m-%d).tar.gz
tar -czvf /tmp/$FILENAME /home/pi/
lftp -c 'open -e "set ftps:initial-prot ""; \
set ftp:ssl-force true; \
set ftp:ssl-protect-data true; \
put /tmp/$FILENAME; " \
-u "USERNAME", "PASSWORD" \
ftps://ftp.box.com:990/Automation/RPI/Backups
It creates the archive and connects to the server fine, but it gives me this error:
put: /tmp/$FILENAME: No such file or directory
I have tried replacing $FILENAME with "backup-$(date +%Y-%m-%d).tar.gz", but that still returns
put: /home/pi/+%Y-%m-%d).tar.gz: No such file or directory
and using "backup*.tar.gz" returns similar. I can only get it to work if I use the specific file name in place of any variables or wildcards, but this doesn't work for me since I want to set up a cron job to back up automatically.
So, does anybody know how to get around this, or a better alternative? Thanks!