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


  • How can i use this script to upload directory to one drive?
    2 Posts | Last post January 28, 2019
    • Can we use this script for uploading directory to one drive. what changes is need to be made?
    • Hi
      easiest way, install OneDrive client and change the Target to the synced Folder
      Advanced, user the OneDrive API, maybe we will add this to the next release
      
  • Problem with $versions
    3 Posts | Last post January 28, 2019
    • I had issues with old backups not being deleted and I found that the sort order in Delete-Backupdir is the wrong and it is deleting the most recent folder (the one it is currently using).  This loses all log messages so far and leaves the old folders.  I reversed the order and changed the if statement around it to a while in case the number is ever reduced.  I also am unable to use the zip option because it hits a memory exception when the file is too large.
    • That is a great catch AlaskanShare, and one I also noticed as well.
      
      To correct this incorrect code, instead of re-writing the entire function, or statement, simply change the following:
      
      #This will remove the oldest backup first
      Select-Object -First 1 --> Select-Object -Last 1
      
    • Thanks, is fixed with release 1.4
  • Square Brackets
    1 Posts | Last post October 05, 2018
    • Hi, 
      
      I've come across a issue when I have sub folders I am backing up which include square brackets [ and ] in the folder name - the script does not backup the contents of these folders.
      
      I understand this is a power shell feature whereby they added square brackets to the wildcard character set to support "blobbing" from v2 onward.
      
      Any ideas how to get around this without having to rename the folders if at all possible
      
      Thanks in advance.
  • Backup to Azure File Share
    1 Posts | Last post August 29, 2018
    • is it possible to backup files Azure file share based on URL & SAS Key by using this script? If so where can enter those variables?
  • Restore function?
    2 Posts | Last post July 27, 2018
    • Do you have a script that restores the files to their previous location? 
    • no, and not planned
  • Is it normal for the script to run for 2 hours, to backup 1GB?
    2 Posts | Last post July 27, 2018
    • It seemed really slow. Is it normal for the script to take 2 hours, when backing up 3 folders with 1 GB of files?
      I run it from the Windows PowerShell ISE. 
    • i cannot confirm this, i am backing up 80 GB over WiFi in 3-4 Hours.
  • Backup of file/folder
    2 Posts | Last post July 18, 2018
    • First of great script. I am backing up one folder from the D drive to a network drive. It copies all the top level folders over in the directory but it does not copy the files inside each folder. On the window it shows copy data location 1 of 1 ; copy file 6 of 21 and copied 0.00MB of 760.343.30 MB. Then it just sits there. I let it go for a hour just incase 
    • After a hour it jumped to 27000 MB copied. Guess I just had to be patience
  • Is it normal for the script to run for 2 hours, to backup 1GB?
    1 Posts | Last post July 09, 2018
    • It seemed really slow. Is it normal for the script to take more than 2 hours, when backing up 3 folders with 1 GB of files?
  • Scheduled, unattended backup possible?
    2 Posts | Last post June 20, 2018
    • Hi
      
      Is it possible to have this script run at a scheduled time and unattended? I want to have it run after hours when the system is idle. 
      
      TIA
      
      Emil
    • Hi, use your local Task Scheduler for this
  • Backup Delete Directory Incorrect
    4 Posts | Last post May 28, 2018
    • Thanks for the script - perfect start for me as new to Powershell. 
      However I noticed the tidy up of the backup folders is incorrect. It is deleting the latest folder ie not the new one created but the one before it, rather than the earliest folder which meets the retention criteria. The consequence is older folders are retained and the one immediately before the most recent is deleted. 
      I've changed the Delete-Backupdir command so to 
         Sort-Object -Property $_.LastWriteTime -Descending:$True
      ie Descending set to True not False. 
      This then works OK & delete the oldest folder. I presume could also change to Ascending:$False??
    • Mmmm. My correction now doesn't seem to be working either. The selection of the folder to delete seems to be rather random. Re-set to False and seems to be working OK. I'd suggest ignoring all my comments unless anyone knows why such strange effects. Could it be becasue I'm running the script within a minute or 2 of previous run?
    • I have correct this by Change Function Delete-Backupdir command to 
      
      $Folder=Get-ChildItem $Destination | where {$_.Attributes -eq "Directory"} | Sort CreationTime | Select -First 1 
      
      
    • Hi,
      this is fixed by next release
21 - 30 of 43 Items