Article 55F8G Problem With Script

Problem With Script

by
garethnsolomons
from LinuxQuestions.org on (#55F8G)
Hi,

I'm new to Linux and I'm having a problem with a script that I've created. I'm currently on Oracle Linux 7 which is pretty much the same as RHEL 7. I'm trying to create a script to use in a cronjob, which will copy an xml file as well as a directory which was created today. The script should only copy today's folder and xml file - there are multiple files and folders in the folder. I'm trying to use scp (unfotunately I have to use this method). If I run the below script, it does nothing. Doesn't copy any files and doesn't write anything to my simple log file (> /tmp/copybackup.log 2>&1). If I place echo in front of each of the lines, it outputs the following to the log file:
find /dev/dbbackup -type d -name "'AutoFullBackup-20200707*'" -exec scp '{}' root@devln11:/dev/dbbackup/test/ ';'
find /dev/dbbackup -type f -name 'Export-20200707*.xml' -exec scp '{}' root@devln11:/dev/dbbackup/test/ ';'

If I copy this output and paste it in the terminal window, it works perfectly - copies all the right files - but if I run the script... nothing. Please help. Thanks in advance.

Script:

#!/bin/bash
NOW=$(date +"%Y%m%d")
FOLDERTIME='*'
FOLDERNAME='AutoFullBackup-'
FOLDER=$FOLDERNAME$NOW$FOLDERTIME

FILETYPE='*.xml'
FILENAME='Export-'
FILE=$FILENAME$NOW$FILETYPE

find /dev/dbbackup -type d -name '"'"'$FOLDER'"'"' -exec scp "'{}'" root@devln11:/dev/dbbackup/test/ "';'"
find /dev/dbbackup -type f -name ''"'$FILE'"'' -exec scp "'{}'" root@devln11:/dev/dbbackup/test/ "';'"

Please note... I'm running the script as root.latest?d=yIl2AUoC8zA latest?i=qeDffuvhMA8:HPyiV3rKw2Y:F7zBnMy latest?i=qeDffuvhMA8:HPyiV3rKw2Y:V_sGLiP latest?d=qj6IDK7rITs latest?i=qeDffuvhMA8:HPyiV3rKw2Y:gIN9vFwqeDffuvhMA8
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments