use mget to copy newer files only.

I use psftp to connect to a remote sftp server and copy files to a local server and is currently using mget * to copy everything.

Is it possible to copy just the newer files only?

Please advise.

Thanks.
nav2567Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
AlexPaceConnect With a Mentor Commented:
I can think of three ways to do this with Robo-FTP.  Perhaps you could "translate" one of these techniques to your Powershell solution.

A. If you keep a local copy of the downloaded files use RCVFILE "*" /serverdate /ifnewer to download only files where the remote copy has a newer date than the local copy.  The /serverdate option is included to preserve the timestamp on downloaded files.


B. If you run the process on a fixed schedule every X days, hours, minutes etc then you could just download any file with a timestamp after the last run.  If I were you, I would update a  timestamp in a text file or registry setting each time the script runs, that way, if your computer were ever down for a full day, such that it completely missed the scheduled execution time, your script would read from the last ACTUAL run time instead of the last calculated run time.


C. Save a directory listing from the remote server every time the script runs.  The first time you'll download everything but on each subsequent time the script will compare the saved directory listing from the last execution with the current directory listing.  It will identify any changes and download only the things that are different.... well unless that difference is that the file was REMOVED from the server... if that happens you might want to delete the local orphan file or not, your choice.
0
 
giltjrCommented:
No, because there is no definition of "newer".

You would need to write a script that somehow identifies the files you want to download and download only them.
0
 
DavidSenior Oracle Database AdministratorCommented:
One workaround:  DOS/Windows uses a simple flag (archive bit) on the file header to indicate whether the file has changed since its last backup.  That bit could be set off when a mget has successfully run.  Thereafter, if the source file hasn't changed, you know it can be passed over.

Variation:  copy the source file(s) to a zip archive, then ftp the zip to the target.  Unpack the zip if the zip copy is newer than the target copy.
0
All Courses

From novice to tech pro — start learning today.