tyraelshammer777 Posted September 26, 2011 Share Posted September 26, 2011 (edited) I'd appreciate constructive criticism on my little xcopy .cmd batch files below. I made it myself as a batch file I can run real quick before I go to bed or whatever every night. I realize that there is other software to take an image of the whole drive that would be a lot more thorough, but I'm mainly looking at just doing a quick "incremental" backup here and there which would only check for files that have changed since the last backup (based on the archive bit being set to 1 = A or 0 = N). The file names of each of the 10 files are numbered 0 through 9. Just look at the first character of the names (like 1ExportRegistry.cmd for example). I removed my username from the script and replaced it with "ROCKHPC". My computer's name is Snowflake. My OS is Win 7 x86.I realize some of the system files in the WINDOWS folder and whatnot which are running probably wouldn't copy properly. I figure that as long as the system being restored with this backup was at least up to date with windows 7 service pack 1 and all the same updates, it would come out right. I'm not sure.So here's the problem: With the below script, I ended up only backing up 16.8 GB when it should have been closer to 70 GB. It totally skipped my C:\users\ROCKHPC\ folder which is 52.1 GB and contains most of the stuff that's really important (and changes most frequently) which probably happened because my documents/pictures/videos/other important folders are under my admin account. I was wondering what would be the best way to "xcopy" my music and pictures and whatnot out of my user folder. I am the only user on this computer, but also the administrator account.Here it is, and by the way it all executes and runs properly and smoothly. It just doesn't catch "locked/restricted/protected" folders like I actually want it to. That's what I'm asking about, here. Thanks for reading!0 here's the one that initiates everythingCode:@echo offtitle "Snowflake System Backup In 9 Steps"Start "Step 1: Export Registry Data" /wait "C:\Users\ROCKHPC\Desktop\Documents\SnowflakeBackup\1ExportRegistryData.cmd"echo Step 1 Completed!echo.Start "Step 2: Assure Registry Data" /wait "C:\Users\ROCKHPC\Desktop\Documents\SnowflakeBackup\2AssureRegistryData.cmd"echo Step 2 Completed!echo.Start "Step 3: Assure Downloads Data" /wait "C:\Users\ROCKHPC\Desktop\Documents\SnowflakeBackup\3AssureDownloadsData.cmd"echo Step 3 Completed!echo.Start "Step 4: Assure Drivers Data" /wait "C:\Users\ROCKHPC\Desktop\Documents\SnowflakeBackup\4AssureDriversData.cmd"echo Step 4 Completed!echo.Start "Step 5: Assure Program Files Data" /wait "C:\Users\ROCKHPC\Desktop\Documents\SnowflakeBackup\5AssureProgramFiles.cmd"echo Step 5 Completed!echo.Start "Step 6: Assure ProgramData Data" /wait "C:\Users\ROCKHPC\Desktop\Documents\SnowflakeBackup\6AssureProgramData.cmd"echo Step 6 Completed!echo.Start "Step 7: Assure User Data" /wait "C:\Users\ROCKHPC\Desktop\Documents\SnowflakeBackup\7AssureUserData.cmd"echo Step 7 Completed!echo.Start "Step 8: Assure Windows Data" /wait "C:\Users\ROCKHPC\Desktop\Documents\SnowflakeBackup\8AssureWindowsData.cmd"echo Step 8 Completed!echo.Start "Step 9: Assure You!" /wait "C:\Users\ROCKHPC\Desktop\Documents\SnowflakeBackup\9AssureYou.cmd"echo Step 9 Completed!echo.echo.echo.echo.echo.echo Hit any Key to close Snowflake System Backup In 9 Steps!echo.echo.pauseexit1Code:@echo offtitle "Step 1: Export Registry Data"reg export HKLM HKLMbackup.reg /yecho HKLM Exported Successfully!echo.reg export HKCU HKCUbackup.reg /yecho HKCU Exported Successfully!echo.reg export HKCR HKCRbackup.reg /yecho HKCR Exported Successfully!echo.reg export HKU HKUbackup.reg /yecho HKU Exported Successfully!echo.reg export HKCC HKCCbackup.reg /yecho HKCC Exported Successfully!echo.exit2Code:@echo offtitle "Step 2: Assure Registry Data"xcopy /M /E /I /Q /H /Y "C:\Users\ROCKHPC\Desktop\Documents\SnowflakeBackup\HKLMbackup.reg" "D:\SnowflakeBackup\Registry"xcopy /M /E /I /Q /H /Y "C:\Users\ROCKHPC\Desktop\Documents\SnowflakeBackup\HKCUbackup.reg" "D:\SnowflakeBackup\Registry"xcopy /M /E /I /Q /H /Y "C:\Users\ROCKHPC\Desktop\Documents\SnowflakeBackup\HKCRbackup.reg" "D:\SnowflakeBackup\Registry"xcopy /M /E /I /Q /H /Y "C:\Users\ROCKHPC\Desktop\Documents\SnowflakeBackup\HKUbackup.reg" "D:\SnowflakeBackup\Registry"xcopy /M /E /I /Q /H /Y "C:\Users\ROCKHPC\Desktop\Documents\SnowflakeBackup\HKCCbackup.reg" "D:\SnowflakeBackup\Registry"exit3Code:@echo offtitle "Step 3: Assure Downloads Data"xcopy /M /E /I /Q /H /Y "C:\Downloads" "D:\SnowflakeBackup\Downloads"exit4Code:@echo offtitle "Step 4: Assure Drivers Data"xcopy /M /E /I /Q /H /Y "C:\drivers" "D:\SnowflakeBackup\drivers"exit5Code:@echo offtitle "Step 5: Assure Program Files Data"xcopy /M /E /I /Q /H /Y "C:\Program Files" "D:\SnowflakeBackup\Program Files"exit6Code:@echo offtitle "Step 6: Assure ProgramData Data"xcopy /M /E /I /Q /H /Y "C:\ProgramData" "D:\SnowflakeBackup\ProgramData"exit7Code:@echo offtitle "Step 7: Assure User Data"xcopy /M /E /I /Q /H /Y "C:\Users" "D:\SnowflakeBackup\Users"echo UBER FAIL - DOES NOT COPY ANYTHING (USEFUL)exit8Code:@echo offtitle "Step 8: Assure Windows Data"xcopy /M /E /I /Q /H /Y "C:\Windows" "D:\SnowflakeBackup\Windows"exit9Code:@echo offtitle "Step 9: Assure You!"echo Your Backup Is Completed And Your Data Is Safe!echo.echo Hit Any Key To Close This Window!Echo.pauseexit Edited September 26, 2011 by Tripredacus code tags Link to comment Share on other sites More sharing options...
allen2 Posted September 26, 2011 Share Posted September 26, 2011 (edited) I would use robocopy instead of xcopy to have good logging options and better choice for incrementals copies (for example filtering). Also the "/B" switch of robocopy might help copying some more files. Edited September 26, 2011 by allen2 Link to comment Share on other sites More sharing options...
tyraelshammer777 Posted September 26, 2011 Author Share Posted September 26, 2011 Using Robocopy managed to grab my Desktop folder (whereas xcopy wasn't able to do that) from C:\users\ROCKHPC. I still was unable to get any pictures and whatnot. Thanks for the post, allen! Link to comment Share on other sites More sharing options...
theeXeic Posted September 27, 2011 Share Posted September 27, 2011 Does your win7 has only one user (you)? The problem you are having is most likely to occur because you lack authority. Even if you are an admin, you cannot access some files because they are owned by microsoft, wheather there are in use or not.Try studying takeown and icacls commands and try your batch again. Link to comment Share on other sites More sharing options...
tyraelshammer777 Posted September 27, 2011 Author Share Posted September 27, 2011 (edited) I am the only account (other than the 'safe mode' Administrator account which I obviously renamed to some strange set of characters) on the computer - and yes I am in the "Administrators" group as well. The thing is that windows 7 automatically runs in less-than-administrator mode by default most of the time, so that's probably what has me locked out. I was thinking that if I saved all my pictures/music/documents and stuff on another partition and just accessed them there, I wouldn't be having this problem. It's probably best to have 1 partition (like 25 or 30 GB maybe) for the system files and OS (WINDOWS folder and whatnot) and another partition for user files. That would probably make the backup a lot easier. Comments? I'll take a look at your commands anyway when I get time, Hybrid. I haven't really taken a look yet. Edited September 27, 2011 by tyraelshammer777 Link to comment Share on other sites More sharing options...
theeXeic Posted September 27, 2011 Share Posted September 27, 2011 I was thinking that if I saved all my pictures/music/documents and stuff on another partition and just accessed them there, I wouldn't be having this problem.Highly unlikely. If you can't copy them from where they are now, the same result would apply if they were on any other partition/drive.It's probably best to have 1 partition (like 25 or 30 GB maybe) for the system files and OS (WINDOWS folder and whatnot) and another partition for user files. That would probably make the backup a lot easier.No the best choice because: 1. windows 7 uses approx 8GB of space. Once you'll update the system, the size will increase drastically. Plus (depending on your settings and usage): hibernation file/page file size/programs and games/temporary files (ex: extracting an 4 gb file with winrar)/logs and memory dumps (I've seen dmps of 500mb) . Think carefully. Unless you want to learn how to move system folders from one drive to another and correct their paths in the registry, i would recommend that you do not try to install a programs/games on another partition. The reason is simple: it will be installed in both places (half on program files in c: and other parts in your defined drive).Beside the ownership problem, xcopy could also not copy folders because they have spaces. xcopy /M /E /I /Q /H /Y "C:\Program Files" --> only program files is enclosed in quotes. I'm thinking, if it reaches a folder in program files with spaces, then it'll skip that folder and move to the next. Just a theory.Perhaps a loop would be better:for /f "tokens=*" %%a in ('dir/b/ad "%programdata%"') do ( robocopy.exe /e "%%a" SOMEWHERE>nul 2>&1)and see how it goes. i hope this is the correct syntax for robocopy. Link to comment Share on other sites More sharing options...
bphlpt Posted September 28, 2011 Share Posted September 28, 2011 But he was only asking about moving the user files (ie C:\Users) to another partition. That is perfectly alright to do. That's what I do as well.Cheers and Regards Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now