LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Ubuntu (https://www.linuxquestions.org/questions/ubuntu-63/)
-   -   Copy newest 2 files from Ubuntu to Windows server (https://www.linuxquestions.org/questions/ubuntu-63/copy-newest-2-files-from-ubuntu-to-windows-server-4175520016/)

aabfm 09-25-2014 04:34 AM

Copy newest 2 files from Ubuntu to Windows server
 
Hi all,
After creating the backup files both from my MySQL database and my online app, I'd like to backup them into my Windows office server.
For that purpose I came up with a script that does all of this but I can't get no copy at all of those files on the server.
Here is that bit of the script that I thought should have done that:

Code:

find -name 'bck*.tgz' -type f -mmin -10 -exec smbclient \\\sbs\\officeserv\\app_backups -u myuser@officeserv.local -p welcome123 -c "; prompt; put "{}"; exit" \;
If I run only the command
Code:

find -name 'bck*.tgz' -type f -mmin -10
it will actually return those two files, however I haven't been able to copy them to the server.
Can you help me?
Thanks

michaelk 09-25-2014 12:35 PM

The basic syntax for coping files via smbclient is
smbclient //host/share -U username -P password -c "put source destination"

So to copy files via find is:
find -name 'bck*.tgz' -type f -exec smbclient //host/share -U username -P password -c "put {} /{}" \;

You can also use a credentials file instead of username password.

aabfm 09-26-2014 07:56 AM

Oops... Not yet...
 
Thanks, for your support but unfortunatelly it doesn't work.
I even tried to change the / or // by \ or \\ but nothing...
Any ideas?

aabfm 09-26-2014 07:59 AM

Other option
 
It doesn't have to be with 'find', I just want to copy the 2 files that were previously created with the script...
Any ideas?
Thanks

michaelk 09-26-2014 07:59 AM

Have you tried copying the files by just using the smbclient command? If so what were the errors?


All times are GMT -5. The time now is 05:34 PM.