Send a file from Windows to Unix as a nightly schedule

6,108

Solution 1

This can be done using a Windows task, and WinSCP.

First, go and install WinSCP http://winscp.net/eng/index.php Once that is installed, click New, then enter the information for your server. If you are using keys, locate the key files, otherwise enter the password. Click save. In the dialog that comes up, be sure to check "Save password" if you aren't using key files. Remember the profile name that you chose.

Next Create a file, config.txt in the same location you installed WinSCP in the file insert the following, replacing the ** with things specific to you.

option batch on
option confirm off
open *NAME OF PROFILE* synchronize local -mirror *Local path: \\servername\location\common* *Remote Path*
exit

Press Windows Key + R

Then type taskschd.msc /s click okay. In the right hand side of the window that opens select Create Task... Enter a Name: Folder Auto Upload (or whatever suits you)

Click on the Triggers tab then click New Select the Daily radio button There will be a time listed, Adjust the time to when you want the upload to happen. Click OK

Click on the Actions tab click New in the Program/script field enter the location of the WinSCP.exe (or browse to where you installed it and select it.) in the Add arguments (optional): field enter /console /script=config.txt then click OK click OK again, and you should be all set.

Solution 2

I would either use a free software like "AlwaySync" to send my files over SFTP/SSH. Or I would set up an ISCSI/SMB share on the remote system, and back up that way. Or I would install Cygwin, and set up rsync to backup to the Linux server on a cron.

These are just concepts to get your brain juices flowing!

Solution 3

You could install putty, and use pscp with schedule tasks. If security wasn't a priority, you can do the same with the built in ftp client on windows.

In my case, i use putty and pscp from the gow distribution of unix tools

A basic file transfer would be of an entire directory would be something like 'pscp -pw password -r "path/to/source/" [email protected]:/path/to/destination/' - there's some problems with this approach, such as having your password in plain text

Using pagent would be a better approach - you'll have to set it up, and replace -pw password with -agent i believe.

IIRC if you wanted to go the rsync route deltacopy might be a good option, it does scheduled incremental backupsh

Solution 4

You could share the folder and file on windows. Install Samba on linux mount the folder and run a cron job on linux to transfer the files where needed

Solution 5

Since you have the thing available over SMB, I would handle this from the Unix side. That means I would set up a cron job (probably using an non-root user account) which does the transfer using either

  • rsnapshot -- which is a good backup utility (and comes with instructons about how to set up cron)
  • rsync -- if your problem is more file-synch rather than backup.
Share:
6,108

Related videos on Youtube

Rajeshkumar
Author by

Rajeshkumar

Updated on September 18, 2022

Comments

  • Rajeshkumar
    Rajeshkumar over 1 year

    Let's say I have a common directory on a Windows server such as: \\servername\location\common. During the day, any user can come and add/remove files to that Windows directory.

    How would I setup a nightly schedule (always 9pm) to transfer all files in that directory over to a Unix server at a pre-defined path (that does not change)?

    I'm not too concerned about hiding passwords as everyone knows them.

    • Is there some well-known script to do this?
    • If not, does anyone have any tips on how I could implement this?

    I have some knowledge of .bat files and shell.

    • Rajeshkumar
      Rajeshkumar about 12 years
      @m0skit0 - that is part of the question, I'm open to optinos.
    • m0skit0
      m0skit0 about 12 years
      Are the files text or binary?
    • Rajeshkumar
      Rajeshkumar about 12 years
      text (i believe ascii win format with crlf linebreaks)
    • m0skit0
      m0skit0 about 12 years
      Are they the same files that change content or totally new different files?
    • Rajeshkumar
      Rajeshkumar about 12 years
      @m0skit0 - they could be either, likely different files. The intention is not to do a backup but instead to execute some SQL contained in the files through sqlplus.
    • Rajeshkumar
      Rajeshkumar about 12 years
      @m0skit0 - bounty up for grabs if you can provide more detail and a recommendation.
  • Rajeshkumar
    Rajeshkumar about 12 years
    thanks for the ideas. The idea is not to do backups but instead run some SQL contained in those files against the unix server.
  • Thalys
    Thalys about 12 years
    in which case, cygwin might be a good option since it has scp, and a cli ssh client for easier scripting
  • Rajeshkumar
    Rajeshkumar about 12 years
    bounty up for grabs if you can provide more detail and a recommendation.
  • Rajeshkumar
    Rajeshkumar about 12 years
    bounty up for grabs if you can provide more detail and a recommendation.
  • Thalys
    Thalys about 12 years
    Answered, though not as tested as i'd like with respect to pagent.
  • Rajeshkumar
    Rajeshkumar about 12 years
    How would you transfer the files between svn and a specified directory on the unix server?
  • m0skit0
    m0skit0 about 12 years
    The SVN server would be on the UNIX server, there you can specify any directory you want it to keep the files in. On the SVN client side, you just do a SVN commit on that SVN repository and all changes (and only the changes) are updated to the server, which make upload faster and with less bandwith consumption (and with optional comments as well). It's just one line using SVN command line client, which can be programmed as a Windows task to do the commit anytime you want automatically.
  • Rajeshkumar
    Rajeshkumar about 12 years
    Do I need root access to install rsync or does it come packaged in some linux distros?
  • James
    James about 12 years
    rsync is often installed with standard installations of both desktop and server releases. If you chose a minimal install of the distribution rsync is far from necessity so it's likely not to be installed.