Windows 2008 R2 (or 2012) : Daily backup script of folders to FTP ?

Hi,
I have a Windows Server 2008 R2 system.
And I want to make a daily backup (rotation 15 days) script of some folder to an FTP.

I found this super script : https://gallery.technet.microsoft.com/scriptcenter/The-ultimate-backup-script-819e52ee#content
But no option to FTP.

Do you know how to add an option to save on FTP ?

Thanks for your help :)

February 3rd, 2015 9:12am

If you have a script that looks promising, you can modify it yourself.  Forums are not designed as sources of 'free consulting to create scripts'.  Your best bet is to try making the modifications, and then, if you run into issues, post specific questions in one of the scripting forums, such as the Official Scripting Guys Forum - https://social.technet.microsoft.com/Forums/en-US/home?forum=ITCG

They won't write the scripts for you, but they are very helpful in pointing you in the right direction.

Free Windows Admin Tool Kit Click here and download it now
February 3rd, 2015 5:01pm

Hi Nicopulse,

You can try to sync the backup folder to FTP server, to upload the modified files based on lastwritetime to ftp server, please refer to this script:

$BackUpdateTime  = (Get-Date).Year.ToString()
$BackUpdateTime += (Get-Date).Month.ToString()
$BackUpdateTime += (Get-Date).Day.ToString()
$BackUpdateTime += (Get-Date).Hour.ToString()
$BackUpdateTime += (Get-Date).Minute.ToString()
$BackUpdateTime += (Get-Date).Second.ToString()
$today = (Get-Date -Format yyyy-MM-dd)

 $ftp = "ftp://ftp.mysite.ca/" 
 $user = "ftpuser" 
 $pass = "ftppassword"  
  
 $webclient = New-Object System.Net.WebClient 
 $webclient.Credentials = New-Object System.Net.NetworkCredential($user,$pass) 

 #we specify the directory where all files that we want to upload  
 $Dir="Y:\LocalDirectory\" 
 $LogFile="I:\PowerShell\MyBackup_"+$today+".txt"
 Clear-Host
 #Write-Host $LogFile
 "From:"+$Dir+" (on server01) To:"+$ftp | Out-File $LogFile -Append
 "Start: "+(Get-Date) | Out-File $LogFile -Append

 $files = @(Get-ChildItem -Path  $Dir -Recurse | ?{ !$_.PSIsContainer } |Where-Object { $_.lastwritetime -gt (get-date).AddDays(-1)} | Select-Object -ExpandProperty FullName )
 foreach($item in $files)
 {
     if($item -ne $null)
  {
   $uri = New-Object System.Uri($ftp+$item.Substring(3))
   $webclient.UploadFile($uri, $item)
   #Write-Host (Get-Date)$item
   "$(Get-Date): "+$item | Out-File $LogFile -Append
  }
 }
 $webclient.Dispose()

 "End:"+(Get-Date) | Out-File $LogFile -Append

Refer to:

PowerShell Backup from Local folder to FTP location

In addition, to manage folders in FTP server, please also check this module to help us to download and upload:

PowerShell FTP Client Module

If there is anything else regarding this issue, please feel free to post back.

Best Regards,

Anna Wang

February 4th, 2015 7:09am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics