Script to schedule network backup and retention

norman1nz

New member
Using Windows 7 / 2008 built in backup utility replacing NTBAckup it's no longer possible to backup to a UNC path from GUI, however with wbadmin command it is..

Having tried this it seems to work ok but each backup overwrites the contents of the previous one but leaves date in the foldername the same..


I think a way to get around this would be to move, at the end of each backup, the files from destiantion into another folder so the next time it executes it creates a brand new correctly dated folder.


I could then run another script to remove old backups automatically.


This is my rough batch file but I guess could be improved:
1) Do you see any errors in this syntax?
2) Is there a better way of doing any of this
3) Do I need to include the date/unique ID in destination folder so Catalog folder and MediaID files aren't overwritten daily (how?) or does it not matter if they are?


Code:
rem use Win 2008 wbadmin to backup server to UNC path 
wbadmin start backup -include:c:,d: -backupTarget:\\destpath\servername -quiet>>C:\Win2008_Backup_Script\backup_log.txt

rem  robocopy to move daily backup to subfolder named date.
robocopy /MOVE \\destpath\servername\WindowsImageBackup\servername \\destpath\servername\Daily_Mo-Th\%date% z /e /log+:C:\Win2008_Backup_Script\robocopy_log.txt /w:5 /r:20 /np /eta 

rem remove files older than two weeks
forfiles /p \\destpath\servername\Daily_Mo-Th\ /s /m *.* /d -10 /c "cmd /c del @file : date >= 14 days"
 

My Computer

OS
Windows 7 Pro x64
I don't know if I can help as I am not familiar with backing up to a server. However, the way you explain it it basically works the same as it does for regular home backups. If I backup to an external hard drive it will overwrite the previous image. To resolve that if you want to keep multiple backups you can move the backup to a different Hard drive, you can put the backup into a folder, or to me the simplest way is to rename the backup. When the backup runs it will be Windowsimagebackup. I simply rename it to the date ie. 4-23windowsimagebackup. It will then run a new backup. That way you can select which backup to restore. The only thing to rememeber is to restore the backup you have to name it back to the original name. I hope this helped some.
 

My Computers

System One System Two

  • Computer type
    PC/Desktop
    Computer Manufacturer/Model Number
    ALWAYS UNDER CONSTRUCTION
    OS
    Windows 11 Pro
    CPU
    Ryzen 9 5900X
    Motherboard
    Asus X570 Crosshair Viii Hero
    Memory
    32GB G Skill DDR4-3600
    Graphics Card(s)
    EVGA RTX 3080 FTW 3 Ultra
    Sound Card
    On Board/Sennheiser PC37X Headset
    Monitor(s) Displays
    3 X Asus 27"
    Screen Resolution
    2560x1440
    Hard Drives
    2 X 1 TB NVME drives
    PSU
    EVGA 850
    Case
    Phanteks Eclipse P400A
    Cooling
    EVGA 280 AIO
    Keyboard
    Logitech G510s/ Logitech G13
    Mouse
    Logitech G502
    Internet Speed
    24/1
    Antivirus
    ESET/MBAM Pro/SAS Pro
    Browser
    Chrome/ Firefox/ Edge
  • Computer type
    Laptop
    System Manufacturer/Model Number
    Dell 16 Plus
    OS
    Windows 11 Pro
    CPU
    Intel Ultra 9 288V
    Memory
    32 GB LPDDR5X 8533
    Monitor(s) Displays
    16" Mini-LED HDR600 Touch 90 Hz
    Screen Resolution
    2560X1600
    Hard Drives
    1 TB NVME
Back
Top