Not able to robocopy single file from Windows XP SP3 workstation - windows

Hi Robocopy Specialists,
I am not able to transfer a backup file to server using robocopy from Windows XP SP3 workstation with the following batch file:
#echo off
………..
set "LOCAL_BACKUP_PATH=H:\Backup\%LOCALDATESTAMP%"
set "REMOTE_BACKUP_PATH=X:\Backup\%REMOTEDATESTAMP%"
md "H:\Backup\%DATESTAMP%" 2 > nul
rem "%ProgramFiles%\7-Zip\7z.exe" a -tzip "%LOCAL_BACKUP_PATH%\%BACKUP_FILE%" "H:\Backup\%LOCALDATESTAMP%\Images.db" "H:\Backup\%LOCALDATESTAMP%\Images.log" >> "H:\Backup\blog.txt"
c:\robocopy\robocopy.exe "%LOCAL_BACKUP_PATH%" "%REMOTE_BACKUP_PATH%" "%BACKUP_FILE%" /COPY:DATS /w:1 >> "H:\Backup\blog.txt"
Below is the robocopy output:
----------------------------------------------------------------------------
ROBOCOPY :: Robust File Copy for Windows :: Version XP010
----------------------------------------------------------------------------
Started : Thu Dec 29 18:00:22 2017
Source = H:\Backup\171229_1800\
Dest : X:\Backup\171229\
Files : Backup_171229180022.zip
Options : /COPY:DATS /R:1000000 /W:1
----------------------------------------------------------------------------
NOTE: NTFS Security may not be copied - Source may not be NTFS.
0 H:\Backup\171229_1800\
----------------------------------------------------------------------------
Total Copied Skipped Mismatch FAILED Extras
Dirs : 1 0 1 0 0 0
Files : 0 0 0 0 0 0
Bytes : 0 0 0 0 0 0
Times : 0:00:00 0:00:00 0:00:00 0:00:00
Ended : Thu Dec 29 18:00:22 2017
This setup has worked when transferring from a Windows 7 Pro w/s to the same server where source folder is from NTFS volume (Robocopy kept adding backslash in Windows 7 batch script).
Below are differences between Windows 7 Pro setup to this one:
Workstation on Windows XP SP3 is the source folder is a FAT32 volume (H:). I have removed the S flag (from /COPY:DATS to /COPY:DAT) which eliminates the need to copy NTFS security attributes but still no backup file been transferred.
Use an alternative source folder from a NTFS volume (D:) also not able to transfer the same backup file either.
No need for compression done by vendor application backup.
Use an old C:\Robocopy\ROBOCOPY.exe as opposed to Windows 7 Pro native C:\Windows\Systems32\ROBOCOPY.EXE.
I ran out of ideas and would appreciate your expert advice.
Thanks again,
George

Robocopy displays the output correctly.
Your robocopy output says that it has not found a file with this name and that's why no file is copied.
Total Copied Skipped Mismatch FAILED Extras
Dirs : 1 0 1 0 0 0
Files : 0 0 0 0 0 0
Make sure this file exists before you commit Robocopy to copy anything. Otherwise give a message in your log file that this file does not exist.
if exist "%LOCAL_BACKUP_PATH%\%BACKUP_FILE%" (
robocopy ...
) else >> "H:\Backup\blog.txt echo "%LOCAL_BACKUP_PATH%\%BACKUP_FILE%" not found.

Related

Cannot delete desktop.ini and albumart.jpg files from command prompt

I know that it is stupid but I cannot delete certain files from command prompt (desktop.ini and albumart.jpg's):
C:\Users\myprofile\Desktop\music>del desktop.ini
Could Not Find C:\Users\myprofile\Desktop\music\desktop.ini
but
C:\Users\myprofile\Desktop\music>dir /a desk*.*
Volume in drive C has no label.
Volume Serial Number is ****
Directory of C:\Users\myprofile\Desktop\music
02.08.2007 13:48 358 desktop.ini
1 File(s) 358 bytes
0 Dir(s) 151 366 811 648 bytes free
Any ideas?

Backup files on Windows 10 computer

I'm supposed to backup a Windows 10 computer. This means copying specific filetypes e.g. .pdf, .doc, .xls, .jpg etc.
I've tried with xcopy but the backup doesn't get complete due to the fact that the computer apparently has folderpaths that are longer than 254 characters.
Therefore I googled, and found Microsofts robocopy, which can handle that particular problem (among others).
Robocopy is a foldercopy utility and not so much a filecopy utility, but with some parameters it should be able to solve the problem.
I created a batch file witch contains these two lines (+ all the rest of the relevant filetypes)
robocopy c:\ d:\B20180602\ *.pdf /s /A-:SH
robocopy c:\ d:\B20180602\ *.doc /s /A-:SH
The odd thing is that it now copies without problems (regarding to foldernames larger than 254 characters), but the final result of this backup is incomplete. There are several subfolders that aren't copied.
Is there anybody that can give me a hint? Thanks in advance.
UPDATE #1 *
After #selbie's advice I ran this one particular command (as Administrator):
robocopy c:\ d:\B20180602\ *.pdf /s /A-:SH
With the following result:
Total Copied Skipped Mismatch FAILED Extras
Dirs : 761465 761351 1 0 113 0
Files : 1233 1233 0 0 0 0
Bytes : 1.464 g 1.464 g 0 0 0 0
Times : 1:58:47 0:00:50 0:00:00 1:57:56
Speed : 30918074 Bytes/sec.
Speed : 1769.146 MegaBytes/min.
Ended : 4. juni 2018 21:32:21
Elevating to Administrator changed a lot. I will make some statistical samples tomorrow and thereby answer whether the problems is solved.
Thanks in advance

undeletable 0 byte file

I have a file in Wnidows/System32 that has a size of 0 bytes.
It's shown there in explorer and command prompt, bu I can't delete nor overwrite it. the system claims the file would not exist, but it stays there even after reboot.
The problem causes the installation of an app to fail because the installation also fails to overwrite the file.
I tried to delete via console,
I tried checkdisk, fileassassin, unlocker etc. all failed to delete the file.
I would be glad if anyone could help?
The system is a virtual Windows 2008 R2 server
c:\Windows\System32>dir /x msvcp*
Volume in drive C has no label.
Volume Serial Number is ECD7-BEFA
Directory of c:\Windows\System32
13.08.2014 15:17 0 msvcp100.dll
05.11.2012 23:26 661.456 msvcp110.dll
11.09.2013 19:39 614.000 MSVCP1~1.DLL msvcp110_clr0400.dll
14.07.2009 03:41 597.504 msvcp60.dll
4 File(s) 1.872.960 bytes
0 Dir(s) 93.173.768.192 bytes free
c:\Windows\System32>del /F msvcp100.dll
c:\Windows\System32\msvcp100.dll
The system cannot find the file specified.

7zip command line - archive name from source file name

How can I read name of source file and send it as archive name in 7zip using cmd archive option.
Now I use:
7z a -t7z V:\archive.7z V:\Backup\*.bak
I want to check bak namefile in V:\Backup (there is always only 1 file) and send it as archive.7z - for example if in V:\Backup is 1 file named "20131028_1100.bak" I want to name archive "20131028_1100.7z"
I found this to work:
Get-ChildItem *txt | ForEach-Object {.\7zr.exe a -t7z $($_.Name).replace('.txt','.7z') $_.FullName}
Example:
PS C:\tools> ls
Directory: C:\tools
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2022/08/01 11:00 578048 7zr.exe
-a---- 2022/08/01 11:02 7 hello.txt
PS C:\tools> Get-ChildItem *txt | ForEach-Object {.\7zr.exe a -t7z $($_.Name).replace('.txt','.7z') $_.FullName}
7-Zip (r) 22.01 (x86) : Igor Pavlov : Public domain : 2022-07-15
Scanning the drive:
1 file, 7 bytes (1 KiB)
Creating archive: hello.7z
Add new data to archive: 1 file, 7 bytes (1 KiB)
Files read from disk: 1
Archive size: 133 bytes (1 KiB)
Everything is Ok
PS C:\tools> ls
Directory: C:\tools
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2022/08/01 11:00 578048 7zr.exe
-a---- 2022/08/01 11:20 133 hello.7z
-a---- 2022/08/01 11:02 7 hello.txt
PS C:\tools> ls
you need a .bat script that execute a FOR command like this:
for %%X in (*) do "7zip\App\7-Zip\7z.exe" a "%%~nX.zip" "%%X"
%%X will catch the file name of every file contained in the folder where you will execute the script (in this case V:\Backup\ and only 1 file would be processed), so %%~nX.zip will take that file name
7zip keep source file name to archive
As "capa" said, it is necessary to use shell commands, because 7zip does not provide a command for this case.
The following edited command is available in order to operate with *.bak files and it is working for "7z" compression extension. It is more efficient than "zip" format in compression rate.
7z Format
FOR %%I IN (.bak) DO "c:\Program Files\7-Zip\7z.exe" a -t7z %%~nI.7z %%~nI.
zip Format
FOR %%I IN (.bak) DO "c:\Program Files\7-Zip\7z.exe" a -tZip %%~nI.zip %%~nI.
In the above commands the " * " symbol before .bak is not appeared. Please add it!
Also add the " * " to the end of each command.
*Create a "bat" file for example "compressbak.bat" on *.bak files directory, copy and paste the preferred command(7z or zip), "Save" the content on "compressbak.bat"! This will create named archives of *.bak files in the same folder that *.bak files saved. Also if you running on Windows x64 and you have a x86 version of 7-Zip you have to follow the right path in order to call the 7z.exe file. "c:\Program Files (x86)\7-Zip\7z.exe"
Folder and bat file content!
I hope that it helps you!!!

Windows copy command return codes?

I would like to test for the success/failure of a copy in a batch file, but I can't find any documentation on what if any errorlevel codes are returned. For example
copy x y
if %errorlevel%. equ 1. (
echo Copy x y failed due to ...
exit /B
) else (
if %errorlevel% equ 2. (
echo Copy x y failed due to ...
exit /B
)
... etc ...
)
I'd opt for xcopy in this case since the error levels are documented (see xcopy documentation, paraphrased below):
Exit code Description
========= ===========
0 Files were copied without error.
1 No files were found to copy.
2 The user pressed CTRL+C to terminate xcopy.
4 Initialization error occurred. There is not
enough memory or disk space, or you entered
an invalid drive name or invalid syntax on
the command line.
5 Disk write error occurred.
In any case, xcopy is a far more powerful solution. The equivalent documentation for copy does not document the error levels.
As an aside, you may want to rethink your use of the %errorlevel% variable. It has unexpected results, at least in some versions of Windows, if someone has explicitly done something silly like:
set errorlevel=22
In those cases, the actual variable will be used rather than grabbing the actual error level. The "normal" way of doing this is (in decreasing order since errorlevel is a "greater than or equal to" check):
if errorlevel 2 (
echo Copy x y failed due to reason 2
exit /B
)
if errorlevel 1 (
echo Copy x y failed due to reason 1
exit /B
)
In addition, if you are running Win7 or Win Server 2008 or later, you should look into Robocopy, which is now the preferred mass-copy solution.
It might also be worth pointing out that xcopy doesn't always return the error code you expect.
For example when trying to copy multiple files with a wildcard but there are no files to copy you expect a return error code of 1 ("No files were found to copy"), but it actually returns 0 ("Files were copied without error")
C:\Users\wilson>mkdir bla
C:\Users\wilson>mkdir blert
C:\Users\wilson>xcopy bla\* blert\
0 File(s) copied
C:\Users\wilson>echo %ERRORLEVEL%
0
I believe Copy only returns 0 for success or 1 for failure.
XCopy has documented return codes:
0 = Files were copied without error.
1 = No files were found to copy.
2 = The user pressed CTRL+C to terminate xcopy.
4 = Initialization error occurred. There is not enough memory or disk space, or you entered an invalid drive name or invalid syntax on the command line.
5 = Disk write error occurred.
There is also one point I would like to emphasize: xcopy as well as robocopy can only copy files, but they can't rename them.
While looking at the original situation (copy x y, which looks like a rename to me), I have the impression that the copy command still is the only one suitable for this purpose.
Error# Description
0 No error
1 Not owner
2 No such file or directory
3 Interrupted system call
4 I/O error
5 Bad file number
6 No more processes
7 Not enough core memory
8 Permission denied
9 Bad address
10 File exists
11 No such device
12 Not a directory
13 Is a directory
14 File table overflow
15 Too many open files
16 File too large
17 No space left on device
18 Directory not empty
999 Unmapped error (ABL default)

Resources