Advertisement
Guest User

Untitled

a guest
Jan 31st, 2014
643
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Backup script
  2. # v1.0
  3.  
  4. # This script checks a day of week and do daily or full backup on external
  5. # storage
  6.  
  7. # ============================= Main environment define =======================
  8.  
  9. # Number of day of week
  10. $CurrentDay = Get-Date -uFormat %u
  11.  
  12. # Number of day of week which full backup is run
  13. $FullBackupDay = 5
  14.  
  15. # Filename - current day at format "year-mm-dd"
  16. $FileName = get-date -Format yyyy-MM-dd
  17.  
  18. # add-content -path c:\backup.txt -value "run"
  19.  
  20. #======== TEST filename ===========
  21. # $FileName = "far2"
  22.  
  23. # The path to the directory that will be archived
  24. $FromPath = "x:\share\"
  25.  
  26. #======== The TEST!!! path to the directory that will be archived ====
  27. # $FromPath = "x:\share\test\"
  28.  
  29.  
  30. # The path to the directory that will be archived
  31. $ToPath = "\\backup\storage"
  32.  
  33. # Backup command
  34. $Command = "C:\windows\system32\ntbackup.exe"
  35.  
  36. # Daily Options
  37. $Daily = "/M daily"
  38.  
  39. # Full Options
  40. $Full = "/M copy"
  41.  
  42. # Different Options
  43. $Different = "/M different"
  44.  
  45.  
  46. ##################
  47. # options formerly
  48. $Options = "backup $FromPath /SNAP:on /HC:off /V:no /F $ToPath\$FileName.bkf"
  49.  
  50. # ============================== main backup procedure ========================
  51.  
  52. #       Write-Host "Different backup run"
  53. #
  54. #       $OptionsDifferent = "$Options $Different"
  55. #       echo $OptionsDifferent
  56. #
  57. #       Start-Process $Command $OptionsDifferent
  58. #
  59.  
  60. if ($CurrentDay -ne $FullBackupDay)
  61.     {
  62.         Write-Host "Daily backup run"
  63.  
  64.         $OptionsDaily = "$Options $Daily"
  65.         echo $OptionsDaily
  66.  
  67.         Start-Process $Command $OptionsDaily
  68.     }
  69. else
  70.     {
  71.  
  72.         Write-Host "Full backup run now"
  73.  
  74.         $OptionsFull = "$Options $Full"                
  75.                 echo $OptionsFull              
  76.  
  77.         Start-Process $Command $OptionsFull
  78.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement