how to copy files in use with robocopy? - backup

I am having a batch file performing some backup operations.
The backup operations look like this:
robocopy %source% %root%\%targetname% /MIR /R:0 /W:0 /NFL /NDL /NJS
Unfortunatly some files in use cannot be copied due to windows "protection".
Is there the possiblity to copy files in use?
I am using windows 10.
The backup included in windows 10 is not flexible enough, i cannot just copy some folders and so on.

According to Wikipedia:
Robocopy does not copy open files. Any process may open files for exclusive read access by withholding the FILE_SHARE_READ flag during opening. Even Robocopy's Backup mode will not touch those files.

Related

Robocopy Creating Hidden Folders On Backup Drive

I am using Windows 11 Pro (since late November '21), before that Win 10 Pro.
For many years I have been happily backing up my files [ROBOCOPY] to a hidden NAS share but recently I retired the NAS and moved to a USB solution (USB Docking Station, 2TB Drive), removing drives in between backups. Which is where things started to go a bit weird because some of the folders didn't appear on the backup drive. Using TreeSizeFree I can see that the folders and their sub-folders/files are there (all entirely visible, of course) have copied across, I just can't see the folders in question.
Here is a sample line from my script:
robocopy C:\Games E:\Games /v /e /xo /w:5 /r:2 /log+:E:\bak-Games.log /tee /copy:dat /dcopy:t
robocopy S:\ E:\Shared /v /e /xo /w:5 /r:2 /log+:E:\bak-Shared.log /tee /copy:dat /dcopy:d >
The top line works as expected but the bottom one doesn't.
I've checked all the switches I'm using and none of them appear to do anything that might account for this behaviour.
I've tried a number of solutions including using the "/a-:sh" switch, making sure that files aren't hidden and pre-creating the folder in question but it just makes them invisible.
The only thing that appears to be a common factor between lines of the script that work and those that don't is that the ones that do are copied from folders (into appropriately named folders on the backup drive) while the ones that don't are copied from partitions i.e. (in the sample script lines above):
robocopy c:\games to e:\games. [WORKS AOK]
robocopy s:\ to e:\shared. [WORKS, ROOT FOLDER NOT VISIBLE]
Any advice appreciated :)
Thanks
James

Move files from Azure storage to a local directory

I want to move all the files that in a File share on azure. I can do it at the moment by following way using:
Use "net" command to connect to the network drive and assign it a drive letter
Then there's a bat file that uses "move" command like move g:\files\* c:\files to then move the files which runs every hour to check if there are files and move them using windows task scheduler.
But I don't want to use this way because:
The drive will be disconnected if the Machine needs a restart and hence the process doesn't remain automated as someone will have to mount the drive again
The "move" command doesn't moves folders, it moves only files.
Is there a better way of managing this? We don't want to install tools like AzCopy but using Powershell is feasible.
According to your description, I suggest you can do it as the following ways:
1.Call Azcopy in PowerShell.
You could install Azcopy firstly, you could download the latest version from the link. Azcopy supports upload directory to Azure fileshare. You could use the following command.
AzCopy /Source:C:\myfolder /Dest:https://myaccount.file.core.windows.net/myfileshare/ /DestKey:key /S
Then you could write a bat script to call Azcopy, by default Azure install directory is C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy.
cd "C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy"
&.\AzCopy.exe /Source:C:\myfolder /Dest:https://myaccount.file.core.windows.net/myfileshare/ /DestKey:key /S
Use PowerShell Script, you could use to this link. The script use for ASM mode, you should change some command.
Based on my experience, using Azcopy is more easily and simpler.
The issue was resolved using the following approach:
Delete any existing mapped drive to the drive letter we are using with the net use <drive_letter> /delete command. This is done to make sure the drive was detached since the last time script ran
Map the drive again using the net use command
Copy all the files using robocopy
After that delete all the files using del command
Disconnect the drive now using the net use <drive_letter> /delete command

Backup Hard drive with robocopy

I am trying to use robocopy to backup my entire hard drive to my external hard drive using the following code
ROBOCOPY C:\ "D:\HD Backup" /e /mir /tee /mt:4 /A-:SH /log:C:\Users\Aaron\Desktop\backup_log_HD.txt
However it takes my 170GB from my hard drive and it was up to 400GB before I stopped it
::
:: Remarks :
::
Using /PURGE or /MIR on the root directory of the volume will
cause robocopy to apply the requested operation on files inside
the System Volume Information directory as well. If this is not
intended then the /XD switch may be used to instruct robocopy
to skip that directory.
You will likely need to add the /XJ flag to exclude junction points.
add /ZB this will make uncopyable files "unlocked", you have to start Robocopy with admin privileges.
More information when it stopped and the error message would be helpful.

Move folder structure from one computer to another computer when these computers aren't networked?

I have two computers that aren't networked. I need to replicate the folder structure of one drive that exists on one computer and put it on the other computer. Both Windows 7 machines. I don't need the files, just folders/directories. The drive letters are the same on both computers (Y). The computers are miles apart physically, but I do have access to the computer I am trying to get the folder structure of via LogMeIn.
I am thinking I need to save the folder structure to a file using some process. Move that file to my computer (via email or LogMeIn File Manager) and run some process to put in on my computer.
Is there a better solution? If not, is there code out there to do this via VBA, Cmd window, .bat script, VB.NET, or VBS? I know I can write it in VBA, but I'd rather not recreate the wheel if I don't have to.
I don't have a 'process'/program that does this. LogMeIn File Manager doesn't do this either (I asked). There are lots of paths on this drive that I need so creating them by hand would take a long time. I searched and found a lot of solutions that work with computers that are networked, but these computers are not networked, hence why I think I need to save it to a file. Again, I don't want all the files on the drive (its huge and most of the files are unnecessary), just folders.
thanks.
Create a directory listing of the source computer and redirect the output to a text file:
dir /ad /b /s >> dirlist.txt
The switches to dir are (more info at MS TechNet):
/ad List only files with attribute of directory
/b Bare format (no heading information or summary)
/s Displays files in specified directory and all subdirectories
Transfer dirlist.txt from the source computer to the destination computer.
On the destination computer, use a for /F with that text file from the command prompt to create the directory structure:
for /F "delims=" %i in (dirlist.txt) do md "%i"
The switches to for are documented at MS TechNet
You have many options:
Windows command xcopy source destination /T /E. The /T option creates the directory structure, and the /E option includes empty directories.
Bundle the empty directory structure into an installer (perhaps as a zip file).
If the structure isn't relatively small and not likely to change, you could just put a bunch of md commands into a batch file.
Combination - xcopy the structure locally, zip it, transfer it, unzip it.

script to move all files from one location to another location

can someone help me with a dos script to move all files from one location to another location
move <sourcepath>\*.* <destpath>
IE, if you wanted to move all files from c:\test\ to c:\test2
move c:\test\*.* c:\test2
if you want to suppress the prompt to overwrite files
move /Y c:\test\*.* c:\test2
If you want to move from the current directory, you can specify just the *.*. Also you can do relative paths. So if you want to move the current directory's files up one directory, you'd do
move *.* ..
.. being the shortcut for "up one directory"
If it's across the network, you can use a UNC path to authenticate as the user you're logged in as or map a drive (using the NET USE command) to specify a username/password on the remote computer, then copy using that drive letter. You can then delete the drive letter after you're done. UNC paths look like \\computer\share\folder\file.txt
I think this one
C:\> MOVE /Y *.* C:\Destination
should be corrected.
Use Robocopy. In Windows 7 and Windows Server 2008 R2 you can even run it multi-threaded using the /MT[:n] switch. From my daily "sync-before-shutdown" script:
Robocopy "d:\dev" "\\dolores\backups\carrie\dev" /e /MT /njh /njs /nc /np /nfl /ndl
(all the /n.. switches suppress console output which helps to speed up the copying process).
To move the files, use either /MOV or /MOVE (to move all subfolders) instead of /E.