Link to home
Start Free TrialLog in
Avatar of sparks2000
sparks2000

asked on

i need to write a script to copy backup data to a netwrok share day per day

hi guys,
i want to write a script that copies data from a specific directory in windows to a directory in a network share.and i want the script run daily(could be dne with task scheduler) but i need the copies to be named as the per the the date that it was taken. i hope i was clear in my request.Does anyone have a sample or template that i can use it have this script.thank to you all
Avatar of snagsy1980
snagsy1980
Flag of United Kingdom of Great Britain and Northern Ireland image


"xcopy c:\data\* f:\backup\%date:~10,4%_%date:~4,2%_%date:~7,2%_backup\* /Y /Q /S" This is simple Windows Batch file and the task scheduler to create an automated daily backup.
 Save this command in notepad & save as backup.bat file.
 In this the xcopy commands will copy files and folders. The syntax for the command is xcopy [source] [destination] [arguments]. Where source is the folder that you want to backup and destination is the backup on the network drive. The arguments tell xcopy how to handle certain situations. For my script I used /Y to suppress prompting when overwriting files. If you do not include this the script will ask you before copying each file, that wouldnt be automated. /Q doesnt display the file names while copying. /S copies directories and sub directories. You can find more arguments by opening the command windows and typing xcopy /?.
%date:~10,4%_%date:~4,2%_%date:~7,2%_backup will create folder with current date.



Avatar of kadadi_v
Start>run>ntbackup and use the backup wizard as per your requirement daily/weekly & monthly basis.




Regards,

Vijay kadadi
Avatar of sparks2000
sparks2000

ASKER

dear srawale,
i did not get what are the 4,2%...and all the percentages .any way it did not work, it gave me anneror so i had to remove them.can u send it again please??
ASKER CERTIFIED SOLUTION
Avatar of srawale
srawale
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
when i run the script :xcopy c:\dell\* d:\backup\%date:~10,4%_%date:~4,2%_%date:~7,2%_backup\* /Y /Q /S

it gave me this message:
Invalid switch - /_00_backup\*

thanks
xcopy c:\dell\* d:\backup\%date:~10,4%_%date:~4,2%_%date:~7,2%_backup\* /Y /Q /S

In this script all data of c:\dell folder will copied to d:\backup folder with current year_current month_current date_backup folder in short script will create the destination folder as d:\backup\2008_02_06_backup.

  You cross check the command again. as per my eariler attachment.
Thanks