I have issue with backup folders from server to ftp (NAS). I was using Cobian backup, but after security updates Cobian started don't handle some files what earlier wasn't problem (doc,pdf or some type setup file). I tried change to .bat files script with scheduler help. I was using script
net use X: \\address\Backup /user:logins /p:no
for /f "tokens=1* delims=" %%a in ('date /T') do set datestr=%%a
md X:\*\*_"%date:/=_%"
md X:\*\*_"%date:/=_%"
md X:\*\*_"%date:/=_%"
md X:\*\*_"%date:/=_%"
md X:\*\*_"%date:/=_%"
net stop MSSQL$PAYPREMIUM
net stop ASANYs_labbis
net stop ASANYs_FinvaldaMaxiServer
net stop ASANYs_FinvaldaMaxiServern
robocopy C:\Program Files\Microsoft SQL Server\MSSQL10_50.PAYPREMIUM\MSSQL\DATA X:\1\PAYPREMIUM\DATA /MIR /LOG:D:\LOG\log.txt
robocopy /mir C:\*\ X:\*\*_"%date:/=_%" /COPY:DAT /E /LOG:D:\LOG\log.txt
robocopy /mir C:\Program Files\Microsoft SQL Server\MSSQL10_50.PAYPREMIUM\MSSQL\DATA\ X:\*\*_"%date:/=_%" /COPY:DAT /E /LOG:D:\LOG\log.txt
robocopy /mir C:\ProgramData\*\data\ X:\*\data_"%date:/=_%" /COPY:DAT /E /LOG:D:\LOG\log.txt
robocopy /mir G:\*_K\ X:\*\*_K_"%date:/=_%" /COPY:DAT /E /LOG:D:\LOG\log.txt
robocopy /mir G:\*\ X:\*\*_"%date:/=_%" /COPY:DAT /E /LOG:D:\LOG\log.txt
net start MSSQL$PAYPREMIUM
net start ASANYs_labbis
net start ASANYs_FinvaldaMaxiServer
net start ASANYs_FinvaldaMaxiServern
net use X: * /delete /Y
But robocopy and xcopy did not handled some situations. So after this I try use WinSCP script
option batch abort
option confirm off
open ftp://logins
put -preservetime E:\FILESERVER /disk1/ftp/SRV/FileServer_%TIMESTAMP#yyyymmddhhnnss%
exit
But even this did not handle the situation when from catalog tree with files from 60+GB only copy one folder without files that make trouble. Trouble that when you copy simple you get notifications about path long and another about that cant copy permissions pdf, doc, ppt files. So I need to make that pass this problems and copy as much that not have problem with path long and path long files that make error just skip.
The long path issue you'll have to address by shortening the destination path name; sometimes SUBST can be used to help you get around that problem, if memory serves. Something like:
NET USE X: \\server\dir
SUBST T: X:\subdir\subsubdir\subsubsubdir\anotherlongdir\blah
Cleanup:
SUBST T: /D
As to continuing to copy files after some files get error, I believe robocopy /R:0 /W:0 will help, and XCOPY /C is its counterpart.
Related
#ECHO OFF
SET driveLetter=%~d0
FOR /R %%x IN (*.pst) DO (
ROBOCOPY %%x %driveLetter%\%%x /E /COPYALL /ZB /MT:20 /XJ /R:2 /W:5
)
PAUSE
EXIT
I can't get this working. What I want to do is search the user folder (incl. subfolders) for any .pst files and then copy these to a flash drive.
Pretty simple actually just use xcopy:
xcopy c:\users\%username%\*.pst F:\ /e
(replace F:/ with drive location if its not F).
#ECHO OFF
SET driveLetter=%~d0
ROBOCOPY %USERPROFILE% %driveLetter%\Outlook *.pst /S /COPYALL /ZB /XJ /MT:20 /R:2 /W:5
PAUSE
EXIT
Solution. Thanks to everybody.
I am working on a refresh project, and I am rebuilding and swapping out a lot of computers. When doing a reimage, I have a script I can run which will copy the Desktop, Favorites, and Documents from all user profiles to a network share.
What I don't have yet, is a script for hardware replacements (vs a reimage) that will transfer data directly from the old computer to the new one. As with my other script, I need it to transfer data from the Desktop, Favorites, and Documents folders for all user directories present on the old machine. If I wanted to go a step further, I might exclude specific user profiles such as Public, Default, my own profile, etc, but a more basic script would still work.
I have done some batch scripting on my own, but I'm not sure what the syntax needs to be to have it cycle through all the user profiles on a remote machine.
Here is what I have tried so far:
#echo off
Set /p remotepc=Enter remote hostname:
for /D %%D in ("\\%remotepc%\USERS\*") do (xcopy \\%remotepc%\Users\%%~fD\Desktop "C:\Users\%%~nxD\Desktop" /H /E /Y /K /I /R /C)
for /D %%D in ("\\%remotepc%\USERS\*") do (xcopy \\%remotepc%\Users\%%~fD\Documents "C:\Users\%%~nxD\Documents" /H /E /Y /K /I /R /C)
for /D %%D in ("\\%remotepc%\USERS\*") do (xcopy \\%remotepc%\Users\%%~fD\Favorites "C:\Users\%computername%\%%~nxD\Favorites" /H /E /Y /K /I /R /C)
pause
Following is my command to copy the files in my computer and from my computer to network.
ROBOCOPY "K:\Builds" F:\Builds\ /E /COPY:DAT
ROBOCOPY "E:\" "K:\Shan Khan\" /E /COPY:DAT
How i can make timestamp in destination folder only when copying the file for example
"K:\Builds" when copied to F:\Builds\
F:\Builds\ ---> F:\Builds_26092015
"E:\" when copied to "K:\Shan Khan\Workspace"
"K:\Shan Khan\Workspace"---> "K:\Shan Khan\Workspace_26092015"
Kindly note that K drive is password protected and i manually saved the password while mapping the IP address to K drive.
I tried this lines and it works.
it created the directory in such a way
Fri 06_26_2015
for /f "tokens=1* delims=" %%a in ('date /T') do set datestr=%%a
md F:\Builds\"%date:/=_%"
ROBOCOPY "K:\Builds" "F:\Builds\%date:/=_%" /E /COPY:DAT /DCOPY:T
I am trying to run a simple xcopy batch script but I am facing some difficoulties.
Here is the script
SET SRC=C:\FOLDER1\FOLDER2
SET DEST=V:\FOLDER1
FOR /D %%d in (%SRC%\*) do xcopy /S /I /y /exclude:%SRC%\exclude.txt %%d V:\FOLDER1\%%~nxd
Basically this script should copy some of the subfolders of C:\FOLDER1\FOLDER2 (excluded.txt contains a list of directories to exclude) and its content to the destination. However when I run the scripts, altough no errors are thrown, NO FILES OR FOLDERS get copied. What am I doing wrong?
Interestingly if I run the following script INSIDE FOLDER2, everything procedes as expected.
FOR /D %%A in (*) DO xcopy /S /I /y /exclude:exclude.txt %%A V:\FOLDER1\%%A
xcopy "C:\FOLDER1\FOLDER2" "V:\FOLDER1" /e /i /y
You mention nothing about excluding any folders.
Using Robocopy to merge two user home directories shares from two different servers to a new server, but can't use /purge to mirror deletes because it will delete the other servers stuff.
I need a way to enumerate the folder names from the users$ share on each server, and add it to both path statements in the command below, so I can purge at the Users subfolder level.
Robocopy command:
robocopy "\CurrentServer1\users$" "F:\Users" /E /B /COPY:DATSOU /R:1 /W:1 /MT /LOG:"C:\RobocopyLogs\MirrorUsers1.txt"
Can a batch or vbscript do that?
Thanks in advance for any help you can provide.
You could merge both source folders into a staging folder, then mirror that staging folder to the destination folder:
mkdir C:\staging
robocopy \\server1\src C:\staging /e /b ...
robocopy \\server2\src C:\staging /e /b ...
robocopy C:\staging C:\dst /mir /b ...
rmdir /s /q C:\staging