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.4 Star
(21)
20,178 times
Add to favorites
3/23/2019
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • Quick suggestion and advice.
    1 Posts | Last post Sat 4:36 AM
    • 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 Thu 2:23 PM
    • 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!)
  • Error (but works)
    1 Posts | Last post March 23, 2019
    • Michael, how are you?
      
      Congratulations on the script, it's fantastic.
      I made the corresponding modifications, routes, variables, etc ...
      
      The script works but every file that I copy receives an error message.
      
      Something like:
      
      No overhead is found for "IndexOf" and the number of arguments 2.
      In C: \ BackupScript.ps1: 211, character 36:
      
      $ Index = [array] 	:: IndexOf <<<< ($ BackupDirs, $ Backup) +1
      + CategoryInfo		: NotSpecified: (:) [], MethodExceprion
      + FullyQualifiedErrorId	: MethodCountCouldNotFindBest
      
      Thank you very much in advance!
  • Issue coping files
    5 Posts | Last post March 18, 2019
    • Hi
      I have this issue: the script create the folder in staging, counts all files and directory but don't make the copy.  
      I cant figure out where is the problem.
      Can you help me? 
      Thanks
      Emiliano
    • Please see the Log for Details
    • 06.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
      06.03.2019-14:36:10 - INFO: Started the Backup
      06.03.2019-14:36:10 - INFO: Count all files and create the Top Level Directories
      06.03.2019-14:36:10 - INFO: There are 7 Files with  6,27 MB of Files to copy
      06.03.2019-14:36:11 - INFO: ----------------------
      06.03.2019-14:36:11 - INFO: Copied 0 files with 0,00 MB of Files
      06.03.2019-14:36:11 - INFO: 0 Files could not be copied
      06.03.2019-14:36:11 - INFO: Backupduration 0 Minutes and 5 Seconds
      06.03.2019-14:36:11 - INFO: ----------------------
      06.03.2019-14:36:11 - INFO: ----------------------
      06.03.2019-14:36:11 - INFO: Compress the Backup Destination
      06.03.2019-14:36:11 - INFO: Use 7ZIP
      
      7-Zip 18.05 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2018-04-30
      
      Scanning the drive:
      2 folders, 1 file, 1101 bytes (2 KiB)
      
      Creating archive: C:\Users\xxxx\Downloads\Staging\Backup-2019-03-06-40789.zip
      
      Add new data to archive: 2 folders, 1 file, 1101 bytes (2 KiB)
      
      
      Files read from disk: 1
      Archive size: 581 bytes (1 KiB)
      Everything is Ok
      06.03.2019-14:36:11 - INFO: Move Zip to Destination
      06.03.2019-14:36:11 - INFO: Clear Staging
      
      -----
      in the zip file there is only the folder with no files (or subfolder in other tests) inside.
      Thanks
    • I think I have found the issue...
      the line $ExcludeDirs="C:\Users\seimi\OneDrive - Seidl Michael\0-Temp\Dir1","C:\Users\seimi\OneDrive - Seidl Michael\0-Temp\Dir2" #This list of Directories will not be copied
      
      If I don't have directories to exclude and comment # the line, the script made an error : 
      Eccezione durante la chiamata di "Substring" con "2" argomento/i: "La lunghezza non può essere minore di zero.
      Nome parametro: length"
      + $ExcludeString=$ExcludeString.Substring(0,$ExcludeString.Length-1)
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
          + FullyQualifiedErrorId : ArgumentOutOfRangeException
      
      
      or if I change the variable: 
      $ExcludeDirs=""
      the script don't copy anything.
      
      If I put a directory to exclude the script works!
      Regards
      
      Emiliano 
    • thanks, will take care
      
  • Backup by file age
    2 Posts | Last post March 05, 2019
    • Hi Michael, you did a very good backup script.
      
      Is it possible to backup files by age? for example, backup only files with 5 days old.
      
      Best Regards
      Andy
    • will add this as a Feature Request
  • Issue with 7zip part
    2 Posts | Last post February 27, 2019
    • I have an issue with 7 zip part.If i comment 7zip its creating backup folder.But with 7zip it is creating the backup folder but after zip process everything will disappear .
      
      verified 7zip installation path and program -all good . Not sure why this is happening 
    • 27.02.2019-16:48:33 - INFO: Create Backupdir F:-----------------
      27.02.2019-16:48:33 - INFO: ----------------------
      27.02.2019-16:48:33 - INFO: Start the Script
      27.02.2019-16:48:33 - INFO: Check if there are more than 5 Directories in the Backupdir
      27.02.2019-16:48:33 - INFO: Check if there are more than 5 Zip in the Backupdir
      27.02.2019-16:48:33 - INFO: Check if BackupDir and Destination exists
      27.02.2019-16:48:34 - INFO: Started the Backup
      27.02.2019-16:48:34 - INFO: Count all files and create the Top Level Directories
      27.02.2019-16:48:34 - INFO: There are 1 Files with  0.00 MB of Files to copy
      27.02.2019-16:48:34 - INFO: ----------------------
      27.02.2019-16:48:34 - INFO: Copied 2 files with 0.00 MB of Files
      27.02.2019-16:48:34 - INFO: 0 Files could not be copied
      27.02.2019-16:48:34 - INFO: Backupduration 0 Minutes and 5 Seconds
      27.02.2019-16:48:34 - INFO: ----------------------
      27.02.2019-16:48:34 - INFO: ----------------------
      27.02.2019-16:48:34 - INFO: Compress the Backup Destination
      27.02.2019-16:48:34 - INFO: Use 7ZIP
      
      7-Zip 19.00 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2019-02-21
      
      Scanning the drive:
      2 folders, 1 file, 1078 bytes (2 KiB)
      
      Creating archive: F:\-----\Backup-2019-02-27-69950.zip
      
      Add new data to archive: 2 folders, 1 file, 1078 bytes (2 KiB)
      
      Here is the log generated 
      Files read from disk: 1
      Archive size: 559 bytes (1 KiB)
      Everything is Ok
      27.02.2019-16:48:34 - INFO: Move Zip to Destination
      27.02.2019-16:48:34 - INFO: Clear Staging
      Press any key to close ...
  • Exclude a Child folder?
    3 Posts | Last post February 19, 2019
    • Love this script.
      Is it possible to Exclude a child folder that's inside the BackupDirs folder?
      
      Chuck  
    • Hi,
      this is added to the next release
    • that's included in 1.4
  • $Versions="2"
    2 Posts | Last post February 19, 2019
    • $Versions="2" #How many of the last Backups you want to keep
      Also not working(
    • fixed with 1.4
1 - 10 of 40 Items