using call to produce dynamic file names

Advertisement

sales@rwb.com.au
Joined:
Posts:
2
Location:
Australia

using call to produce dynamic file names

Hi all,
I'm using a script that uses `call` to dump a database:
call mysqldump mydb | gzip > /tmp/mydb.sql.gz
this works just fine. But, what I would like is to call the file with a date/time tagged with it. e.g
call mysqldump mydb | gzip > /tmp/mydb_23-04-06_11-23am.sql.gz
of course the 23-04-06_11-23am part needs to be automated.
I can do this by calling a shell script e.g call foo.sh but I was wondering if there were any linux shell gurus who might be able to help me do it straight from the winscp call syntax.
Something like:

option batch on
option confirm off
option transfer binary
call datevar=date '+ %d_%m_%y__%H-%M'
call mysqldump mydb | gzip > /tmp/mydb_$datevar.sql.gz
get /tmp/mydb_$datevar.sql.gz c:\backupfolder\
close
exit

ANOTHER alternative would be to always dump it as the same name in /tmp then do a
`call rename samename namewithdynamicdate
then get it. But alas I can't do this other than in a .sh file , so a solution here is just as sufficient.

thanks
sam

Reply with quote E-mail

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: using call to produce dynamic file names

I'm not a linux guru :-) but you can try following:
call mysqldump mydb | gzip > /tmp/mydb_`date '+ %d_%m_%y__%H-%M'`.sql.gz

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Tried that.... no success

sales@rwb.com.au wrote:

mysqldump test | gzip > /tmp/mydb_`date '+ %d_%m_%y__%H-%M'`.sql.gz
bash: /tmp/mydb_`date '+ %d_%m_%y__%H-%M'`.sql.gz: ambiguous redirect
Well, it works for me, at least on command-line. I haven't tried that via "call".

Reply with quote

Advertisement

You can post new topics in this forum