This is a read-only archive. No new posts or registrations. Privacy Page
Software

backup script problem [newbie]

4 min read

This thread's last reply is from . Advice, software, and links below may be out of date — treat specific steps and download links with caution.

Looking for the outcome? Ask AI

I'm using a backup script, that simply copies files over to a separate partition as a backup. The problem is that I get a 'sharing violation' error and I'm not sure "what file it is talking about". I've looked at the help file of Windows command xcopy and I haven't found any option that is relevant.

Has anyone encountered similar problems and resolved them?

My budget doesn't permit me to purchase enterprise solutions (e.g. Veritas/Symantec) because I'm just backing up a single folder, so a simple solution would be appreciated.

backup script
@echo off
rem xcopy /Y "C:\Documents and Settings\Administrator\My Documents\My Virtual Machines" "J:\Backup\Elsueno\My Virtual Machines" /E /C /H /R /K > backup_1.log
rem xcopy /Y "C:\Documents and Settings\Administrator\My Documents\downloads" "J:\Backup\Elsueno\Downloads in Progress" /E /C /H /R /K > backup_2.log
xcopy /Y "C:\Virtual Machines" "J:\Backup\Elsueno\My Virtual Machines" /E /C /H /R /K > backup_1.log

Attachments:

Another change you should make

> backup_1.log to 2>&1 backup_1.log

What it means is to redirect Standard Error (STDER) to Standard Output (STDOUT). Try it and see is it records the info you need.

Another change you should make

> backup_1.log to 2>&1 backup_1.log

What it means is to redirect Standard Error (STDER) to Standard Output (STDOUT). Try it and see is it records the info you need.


The only problem is that I still require to log the events (not just the errors). I tried updating the command, as follows but, somehow no files are copied when I run this command:

xcopy /Y "C:\Virtual Machines" "J:\Backup\Elsueno\My Virtual Machines" /E /C /H /R /K > backup_1.log 2>&1 backup_err.log
Try it like this, should work:

xcopy /Y /E /C /H /R /K "C:\Virtual Machines" "J:\Backup\Elsueno\My Virtual Machines\" 2>&1> backup_err.log
I haven't done any batch work in awhile so forgot the correct syntax. Please post back with results of how it works for you and if you get the info logged that you need. Good luck.
Well I tried it out, but the error is still not written to the log file. I thought this would work as it should work with ux scripts. For the sake of completeness, I tested it as follows: 1. Denying all rights to a file (expecting an access denied error) 2. Running the backup script The access denied error was written to the terminal but not to the backup.log file.
Jon, Do you say any of the file names of the files being copied? Or does this error occur and that message is all you see? Also are you trying to get the error written to the log only so you can see what file it is, if not you can try the /F argument which will display full sources and destinations, I'm not sure if that will show you the file causing it, but it might. Depending on how many files your trying to copy, you can use the /P method to be prompted to copy each one, it would take a while but you can then copy each file one by one until you reach the error, then look at whats been copied (I think it goes in alphabetical order) and then go to the folder and see what came after the last one it did. Time wasting maybe, but if you are only backing up a few files, it may be worth it. Is anything else written to the log file? Is it always blank or do you get the results of all the successful transfers too?
Your backup_script.bat is still wrong.

@echo off
rem xcopy /Y /E /C /H /R /K "C:\Documents and Settings\Administrator\My Documents\My Virtual Machines" "J:\Backup\Elsueno\My Virtual Machines" > backup_1.log
rem xcopy /Y /E /C /H /R /K "C:\Documents and Settings\Administrator\My Documents\downloads" "J:\Backup\Elsueno\Downloads in Progress" > backup_2.log
xcopy /Y /E /C /H /R /K "C:\Virtual Machines" "J:\Backup\Elsueno\My Virtual Machines" > backup.log

Should be …

@echo off
rem xcopy /Y /E /C /H /R /K "C:\Documents and Settings\Administrator\My Documents\My Virtual Machines" "J:\Backup\Elsueno\My Virtual Machines" 2>&1> backup_1.log
rem xcopy /Y /E /C /H /R /K "C:\Documents and Settings\Administrator\My Documents\downloads" "J:\Backup\Elsueno\Downloads in Progress" 2>&1> backup_2.log
xcopy /Y /E /C /H /R /K "C:\Virtual Machines" "J:\Backup\Elsueno\My Virtual Machines" > backup.log
Duh :wall: Sorry, I missed that completely. Ignore my babbling and I'll go away pretty soon :lol:

So, the line that is not commented out is now:

xcopy /Y /E /C /H /R /K "C:\Virtual Machines" "J:\Backup\Elsueno\My Virtual Machines" > backup.log

and should be

xcopy /Y /E /C /H /R /K "C:\Virtual Machines" "J:\Backup\Elsueno\My Virtual Machines" 2>&1> backup.log

or did you already try that?

Ask AI

AI can make mistakes. Check the cited posts. Archived advice can be out-of-date

Don't include personal information. Questions and selected public posts go to OpenAI. About Ask AI