Computer Hope

Microsoft => Microsoft DOS => Topic started by: DigitalDawn on January 14, 2013, 03:16:09 PM

Title: Xcopy Batch File
Post by: DigitalDawn on January 14, 2013, 03:16:09 PM
Hi,

I created a batch file to perform a daily backup of changed files from my hard disk to a large (Fat32) flash drive using xcopy. I've used the xcopy command successfully with Windows XP for years. But after switching to Windows 7 I've been having difficulty getting the batch file to work correctly with some directories.

The problem is that it doesn't drill down into my users/username/appdata/roaming/Microsoft directories. It does work correctly in most other directories (such as documents), but it doesn't copy sub directories in certain places such as users, and program data.

Here it is:

cd\
xcopy c:\*.* f:\ /s /m /y /c  /EXCLUDE:C:\exclude.txt
cd\

The exclude part works fine. I've been excluding the C:\windows folder and C:\program files folders.

I've tried using the /n /r and /i switches with no luck. I close down all programs before running the batch file. I did try to use Rich Copy but I couldn't figure that program out to save my life :-)

Am I missing something, or is there no way to get xcopy to work properly with Win7?

Thanks.

Title: Re: Xcopy Batch File
Post by: DigitalSnow on January 14, 2013, 03:31:03 PM
A bunch of questions to try to get a better idea of the problem.

Title: Re: Xcopy Batch File
Post by: DigitalDawn on January 15, 2013, 04:04:32 AM
Yes to all your questions. :-)

I'm wondering if this could be a limitation of xcopy itself.

In another forum this is what someone said:

"xcopy cannot copy open/locked files and an admin doesn't own all the file system in Windows now."

What doesn't make sense is that I do have access to these files, but xcopy doesn't for some reason. Is there any way to run a batch file in some kind of admin mode?

As another option I would be happy to buy a program to do this for me. All I'm looking for is a program that copies changed files to a flash drive and then resets the archive bit on the source file. I would like to have the files be readable on any PC, so compression or proprietary formats wouldn't work. An image or clone program wouldn't be the answer either.

Do you know of any programs that could do this?

Thanks.
Title: Re: Xcopy Batch File
Post by: foxidrive on January 15, 2013, 06:44:10 AM
Is there any way to run a batch file in some kind of admin mode?

Right click the batch file and run it as admin/with elevated permissions.

See if that does it as you expect it should.
Title: Re: Xcopy Batch File
Post by: DigitalDawn on January 15, 2013, 07:02:32 AM
No that didn't work either.  :-(
Title: Re: Xcopy Batch File
Post by: foxidrive on January 15, 2013, 07:20:28 AM
The essence of the problem has to do with ownership of files and folders. 
Windows can have multiple users on a machine and the expectation is that they can each have files which other users cannot view or use.

This user system leads to admin users and other classes who can use takeown.exe and cacls.exe to change permissions on the file system and give the ability to access certain system and user folders.

If you have no expectation of security on your computer then you can give permission to each file and folder to "Everyone" which is a user privilege that is very low in the security hierarchy.   Windows isn't designed to allow this - some folders will revert to system access repeatedly -  and this will allow malware to gain access easily too.

Another way around this is to create a folder which you use to save every personal file into, in a category of sub folders, and then backup this 'master' folder which contains all your files.

You might also like to investigate XXclone which can backup the entire hard drive to a USB device (or internal drive) in file mode - and each backup only copies the changed/new files and gives you a mirror and bootable backup.  The benefit is that after the initial backup then each subsequent backup is very swift, of the entire system.  You can access every file in the backup the same way you can on your master drive.  The backup hard drive only needs to be as large as the files, so you can backup to a smaller HDD than the primary c: drive.

Robocopy is a command line tool that is similar to xcopy but it also skips existing files in the backup, so is swift.  It has mirror backup capability too.
Similar to xcopy, it cannot copy files and folders that your user does not have permissions to access.

I hope that illuminates the issue somewhat...
Title: Re: Xcopy Batch File
Post by: DigitalDawn on January 15, 2013, 10:44:24 AM
Thanks for your detailed response.

I checked out XXClone and it really isn't going to work because it requires a full-clone backup initially, which I can't do with a flash drive.  Same thing for Acronis and other similar programs.