PowerShell Backup Script

Copy all your valuable Files to an external Drive, to a Network Folder or in the Cloud. Only configure your Folders you want to save, define your Destination, the Logging level and how many of your old backups you want to stay in your Destination.

BackupScript.zip
 
 
 
 
 
4.5 Star
(23)
22,391 times
Add to favorites
3/23/2019
E-mail Twitter del.icio.us Digg Facebook
  • Nice solution, but doesn't work
    1 Posts | Last post March 14, 2020
    • Took a lot of memory and CPU but only created the backup folder. After 45+ minutes, it exited without any error.
      Backup disk is a WD MyCloud Home 4 TB, mapped as the Z drive.
      
      14.03.2020-09:31:29 - INFO: Create Backupdir Z:\Backups\F\Backup-2020-03-14-20453\
      14.03.2020-09:31:29 - INFO: ----------------------
      14.03.2020-09:31:29 - INFO: Start the Script
      14.03.2020-09:31:29 - INFO: Check if there are more than 3 Directories in the Backupdir
      14.03.2020-09:31:29 - INFO: Check if there are more than 3 Zip in the Backupdir
      14.03.2020-09:31:29 - INFO: Check if BackupDir and Destination exists
      14.03.2020-09:31:29 - INFO: Started the Backup
      14.03.2020-09:31:29 - INFO: Count all files and create the Top Level Directories
      14.03.2020-09:32:41 - INFO: There are 320266 Files with  468 669,27 MB of Files to copy
      14.03.2020-10:16:02 - INFO: ----------------------
      14.03.2020-10:16:02 - INFO: Copied 1 files with 0,00 MB of Files
      14.03.2020-10:16:02 - INFO: 0 Files could not be copied
      14.03.2020-10:16:02 - INFO: Backupduration 44 Minutes and 38 Seconds
      14.03.2020-10:16:02 - INFO: ----------------------
      14.03.2020-10:16:02 - INFO: ----------------------
      <end>
  • i like to copy all file and all folders and there files in the zip file
    1 Posts | Last post February 21, 2020
  • Special Filtypes backup in separate foldername
    1 Posts | Last post December 20, 2019
    • Hi,
      
      this is a very helpful script and I thank you a lot.
      I added some folders that should be in the backup and I want to backup from another folder only  the filetypes *ct5 or *.dat
      Is it possible that you can help me? I am very new to programming. Thank you.
      
      Best Regards
      Tom
  • Files containing [ ] in name ignored
    1 Posts | Last post October 28, 2019
    • Love the script but came across an issue that it does not copy files that have brackets [ ] in their filename. Is this something that can be solved?
  • [Usage] Some returns
    2 Posts | Last post October 23, 2019
    • Hey,
      I just use your script, here are some returns.
      - You should indicate to modify the Set-ExecutionPolicy to execute the script
      - I wanted to copy some files from a network drive, but powershell did not see the mappings, i had to use 'net use'.
      - you should indicate the format to use to declare many backup dirs (values separated by ',' this will be clearer :)
      - And finally, i add some erros, resulting in the no copy of some files:
      Sorry, my system is french but you should see the origin exception
      Impossible d’appeler une méthode dans une expression Null.
      Au caractère C:\Users\xxxxx\BackupScript\BackupScript\BackupScript.ps1:187 : 9
      +         $SumMB+=$colItems.Sum.ToString()
      +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidOperation : (:) [], RuntimeException
          + FullyQualifiedErrorId : InvokeMethodOnNull
      
    • Second part
      Measure-Object : La propriété « length » est introuvable dans les entrées d’objets.
      Au caractère C:\Users\xxxxx\BackupScript\BackupScript\BackupScript.ps1:183 : 94
      + ... bject {$_.mode -notmatch "h"} | Measure-Object -property length -sum)
          + CategoryInfo          : InvalidArgument : (:) [Measure-Object], PSArgumentException
          + FullyQualifiedErrorId : GenericMeasurePropertyNotFound,Microsoft.PowerShell.Commands.MeasureObjectCommand
      Impossible d’appeler une méthode dans une expression Null.
      Au caractère C:\Users\xxxx\BackupScript\BackupScript\BackupScript.ps1:187 : 9
      +         $SumMB+=$colItems.Sum.ToString()
          + CategoryInfo          : InvalidOperation : (:) [], RuntimeException
          + FullyQualifiedErrorId : InvokeMethodOnNull
      22.10.2019-08:25:03 - INFO: There are 0 Files with  0,00 MB of Files to copy
      Tentative de division par zéro.
      Au caractère C:\Users\aurelien\BackupScript\BackupScript\BackupScript.ps1:213 : 13
      +             Write-Progress -Activity $Text $status -PercentComplete ( ...
       + CategoryInfo          : NotSpecified: (:) [], RuntimeException
          + FullyQualifiedErrorId : RuntimeException
      Thanks
  • Great Script !
    1 Posts | Last post August 05, 2019
    • Thanks a lot for sharing
  • Quick suggestion and advice.
    1 Posts | Last post July 20, 2019
    • I just downloaded this as a replacement for the great windows backup. 
      
      I found two issues since but this script is really good. Very well written and easy to use. 
      
      1. First issue I found by default it comes with two destination variables I assumed it would copy to both locations. After testing it I noticed it was just overwriting the variable so I just left it with one destination value. Anyways that's great but just thought it may confuse other users too. Maybe it should be edited to only have the one to prevent that confusion.
      
      2. I noticed the exclude folder issue where if I removed the contents for the directory it didn't backup. I don't need to exclude anything in my backup. So I commented out the lines and removed the variable just wanted to confirm this won't have any impact. Far as I can tell in my little bit of power-shell knowledge this is OK.  
      
      <#
      $ExcludeString=""
      #[string[]]$excludedArray = $ExcludeDirs -split "," 
      foreach ($Entry in $ExcludeDirs)
      {
          $Temp="^"+$Entry.Replace("\","\\")
          $ExcludeString+=$Temp+"|"
      }
      $ExcludeString=$ExcludeString.Substring(0,$ExcludeString.Length-1)
      #$ExcludeString
      [RegEx]$exclude = $ExcludeString
      #>
      
      
      Anyways besides that. Great script thank you so much for this. Was exactly what I was looking for. 
      
  • script stop
    1 Posts | Last post July 18, 2019
    • today I try your script
      It starts but stop and nothing is done
      
      PS D:\Users\mpodgorski\Desktop\BackupScript> .\BackupScript.ps1
      I:\Staging\Backup-2019-07-18-4123\Log.txt
      18.07.2019-08:16:19 - INFO: Create Backupdir I:\Staging\Backup-2019-07-18-4123\
      18.07.2019-08:16:19 - INFO: ----------------------
      18.07.2019-08:16:19 - INFO: Start the Script
      18.07.2019-08:16:19 - INFO: Check if there are more than 5 Directories in the Backupdir
      18.07.2019-08:16:20 - INFO: Check if there are more than 5 Zip in the Backupdir
      18.07.2019-08:16:20 - INFO: Check if BackupDir and Destination exists
      18.07.2019-08:16:20 - INFO: Started the Backup
      18.07.2019-08:16:20 - INFO: Count all files and create the Top Level Directories
      18.07.2019-08:16:26 - INFO: There are 15905 Files with  68 794,46 MB of Files to copy
      
      
      the script stops at this point and nothing happens
      
  • Massif data to backup
    1 Posts | Last post July 12, 2019
    • Hi Michael,
      First I would like to let you know this backup script is fantastic.  
      Here come my question, when I do a backup of one folder, I don't have any problem but when I'm try to backup a Full Drive nothing is happening. It's able to go through the first step 6.03.2019-14:36:10 - INFO: Create Backupdir C:\Users\xxxx\Downloads\Staging\Backup-2019-03-06-40789\
      06.03.2019-14:36:10 - INFO: ----------------------
      06.03.2019-14:36:10 - INFO: Start the Script
      06.03.2019-14:36:10 - INFO: Check if there are more than 7 Directories in the Backupdir
      06.03.2019-14:36:10 - INFO: Check if there are more than 7 Zip in the Backupdir
      06.03.2019-14:36:10 - INFO: Check if BackupDir and Destination exists
      And it stop there. Do you have any idea on how I could I resolve it? and what should I do?
      And it's important to know that I'm using a external drive for the backup.
      stur007 from Quebec
  • File was not copied
    2 Posts | Last post May 04, 2019
    • Hi Michael, I get the following error on all files, whether I try to copy to my network share or even to my hard drive:
      26.04.2019-16:50:44 - ERROR: @{FullName=C:\users\documents\MiscStuff\Archive_Weekly\2017\WeeklyUpdate_1229.docx} returned an error an was not copied
      
      It creates the version folder and the parent folder (i.e. "MiscStuff") just fine, but no files copied.  Any suggestions?  Thanks!
    • Nevermind...case-sensitive(DUH!)
1 - 10 of 46 Items