SFTP upload with variable

The following works fine:

:global backupfile; :global backupname; /tool fetch url=" sftp://10.0.0.2/path/to/filename.backup" user=usr password=passw upload=yes

but I am trying to upload a weekly backup so the name of the file is always different. It worked using FTP fine previously using $backupfile in src-path but if I try src-path with SFTP it fails and disconnects the SFTP connection.

Is it possible to use a variable in SFTP upload or can anyone thing of a workaround?

This is what I have tried so far and it doesn’t work.

:global backupfile; :global backupname; /tool fetch url=" sftp://10.0.0.2/path/to" src-path=$backupfile user=usr password=passw upload=yes

and

:global backupfile; :global backupname; /tool fetch url=" sftp://10.0.0.2/path/to/$backupfile" user=usr password=passw upload=yes

Thanks

I think I need to combine both my attempts and set the variable on the URL and the src-path for it to work.

OK ignore me. I must have not had the variable set correctly. The following works now for me:

:global backupfile; :global backupname; /tool fetch url=“sftp://10.0.0.2/path/to/file/$backupfile” user=usr password=passw upload=yes

I tried the same (I just changed the sftp settings up there) but didnt work.

Can you provide more details about your solution?

Are you also using a variable $backupfile or have you removed that part?

If you enter the command directly in a terminal does it give an error message?

Can you post the command you are trying (removing anything sensitive)?

Is the path you are trying valid?

Thanks for your reply!!

Are you also using a variable $backupfile or have you removed that part?

Im using it
(Im kind of new in scripting)

If you enter the command directly in a terminal does it give an error message?

This message:
“status: failed
failure: Is a directory”

Can you post the command you are trying (removing anything sensitive)?

there is

/system backup save name=([/system identity get name] . [:pick [/system clock get date] 7 11] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . ".backup"); 
/
:global backupfile; :global backupname; /tool fetch url="sftp://10.10.1.1/home/SFTP/userhere/Files/$backupfile" user=userhere password=passhere upload=yes



Is the path you are trying valid?

yes, I did make a upload with the default autobackup.backup archive sucefully in the same path.

Thanks. And if you look in your Environment, what name does $backupfile have exactly?

Hi UNiXMIT,

I managed to figure out what’s goin on with my script and now its fully working.
Your post help me a lot!!
Thanks again.

My script:

:global name=backupfile value=([/system identity get name] . [:pick [/system clock get date] 7 11] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . [/system clock get time] .".backup");

/system backup save name=$backupfile

:put $backupfile

:global backupfile; :global backupname; /tool fetch url="sftp://10.10.10.10/home/SFTP/user1/Files/$backupfile" user=user1 password=passwd upload=yes keep-result=no src-path="$backupfile"

Fantastic. Glad to hear it.