Use Robocopy to back up files
 
robocopy is a tool included in Windows Server (and regular Windows??) to copy whole directories from one place to another. It supports a lot of options such as retries if a file can't be read, logging of errors during copying and much more.

This is an example batch script to perform a backup of files:

@ECHO OFF

SET location=Z:backup
Set Logname=%location%backuplog.txt"

ECHO We're working with %location%
ECHO Logging to %Logname%


mkdir %location%subdir1
mkdir %location%subdir2

rem Use copy to back up single files
copy C:some_file.ext %location%subdir1

rem Use Robocopy to back up whole directories (including subfolders)
Robocopy D:pathtofiles %location%subdir2 /E /DCOPY:T /R:3 /W:5 /TEE /LOG+:%Logname%
Robocopy C:pathto_otherfiles %location%subdir2 /E /DCOPY:T /R:3 /W:5 /TEE /LOG+:%Logname%


rem Back up SQL Server Data (make sure service doesn't run)
ping -n 1 -w 1000 1.2.3.4

net stop MSSQLSERVER

ping -n 1 -w 1000 1.2.3.4

rem Robocopy "C:Program FilesMicrosoft SQL ServerMSSQL10_50.MSSQLSERVERMSSQLDATA" %location%mssql /E /DCOPY:T /R:3 /W:5 /TEE /LOG+:%Logname%
rem Robocopy "D:SQLData" %location%mssqldata /E /DCOPY:T /R:3 /W:5 /TEE /LOG+:%Logname%

ping -n 1 -w 1000 1.2.3.4

rem net start MSSQLSERVER


Note that the /LOG+:C:\Path\to\log\file.txt option has a "+" which denotes that log is appended to the file instead of overwritten.
 
admin / Dec 03, 2014
   
 
 
Login: 
Pass: 
 
 
     
     
2004 - 2019 / lookass.ch
makememad@lookass.ch