• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.
  • The forums have been upgraded with support for dark mode. By default it will follow the setting on your system/browser. You may override it by scrolling to the end of the page and clicking the gears icon.

Having batch file backup problem...help if u can!

Joined
Dec 13, 2006
Messages
160 (0.02/day)
Location
hollywood, fla.
System Name Graves Rig
Processor Q6680 GO @ 3.3Ghz
Motherboard Asus P5k Deluxe wifi
Cooling Zalman 9700 CpuFan
Memory 8GB Crucial Ballistix Tracer 8500/1066
Video Card(s) EVGA Nvidia 8800GTX
Storage 1 WD-Raptor 160GB - 1 WD Caviar 500GB - 1 WD Black Caviar 1.5TB
Display(s) Samsung 931BF 19inch Flat Screen
Case Thermaltake Armor w/200MM side Fan
Audio Device(s) Realtek onboard shizzz
Power Supply SeaSonic M12-700W
Software Windows 7 home premium
Benchmark Scores 3DMark06 Score = 13,664
Hi there.

Was making a batch file to do backups of my important files and it works fine for just about any folder
except for
My Documents.

It copies my firefox mozilla backups fine to my c: drive.
But if i try to copy my documents to D: drive i get invalid syntax, or file not found.

I've tried everything, it just won't do it.

Here's the script:

@echo off
cls
echo Press Any Key to continue backup!
pause
xcopy /s /i d:\backups\Mozilla c:\mozillaback
copy . c:\Documents and Settings\spear\My Documents d:\Backups\My documents
echo Backup has now finnished !

I've spelled the directories exaclty as you see here, no mistakes. It just won't work.
I'm kind of new at this, thanks so much anyone.
!:toast:
 
Because My Documents isnt My Documents anymore. You have to point at the specific directory of the account your backing up
 
Try using "%USERPROFILE%\My Documents". :toast:

EDIT: Actually that's for XP.. This is for Vista/Win7 "%USERPROFILE%\Documents"
 
Last edited:
Here is one I wrote awhile back and it puts your stuff in a folder with the days date and time, and adds a log file. Enjoy! :toast:

Remember to set the path for the following
  • set drive=u:\Backup_Dir
  • set Stuff2Backup=%USERPROFILE%\Documents

Code:
@echo off
:: variables
:: The below varible "drive" needs to have the path where you want to save it.
:: The below varible "Stuff2Backup" needs to be what you want to save.
set drive=u:\Backup_Dir
set tt=%time:~0,2%_%time:~3,2%_Backup
set folder=%date:/=-% %tt%
set backupcmd=xcopy /s /c /d /e /h /i /r /k /y
set Stuff2Backup="%USERPROFILE%\My Documents"


color 9F
echo ### Mindweaver's Backup Plain

%backupcmd% "%Stuff2Backup%\*.*" "%drive%\%folder%\%file%"


echo ### Setting Attribute's

attrib +r -h %drive%\* /s /d

echo This Backup was created on Date (%date%), Time (%time%). >> "%drive%\%folder%\Backuplog.txt"

echo Backup Complete!
@pause

EDIT: Sorry mods for double post.. My back is out of wack and i'm on muscle relaxers.. :p
 
Last edited:
Try using "%USERPROFILE%\My Documents". :toast:

EDIT: Actually that's for XP.. This is for Vista/Win7 "%USERPROFILE%\Documents"

Yes, my machine is WinXP.
Will try the %userprofile% switch......thanks will let u know if it works!;)
 
Hope your back gets better...jealous about the painkillers ya got! lol.
Thanks so much for the script.
didnt need all the colors n fonts, but will look nice....very cool of u...thanks!


Here is one I wrote awhile back and it puts your stuff in a folder with the days date and time, and adds a log file. Enjoy! :toast:

Remember to set the path for the following
  • set drive=u:\Backup_Dir
  • set Stuff2Backup=%USERPROFILE%\Documents\

Code:
@echo off
:: variables
:: The below varible "drive" needs to have the path where you want to save it.
:: The below varible "Stuff2Backup" needs to be what you want to save.
set drive=u:\Backup_Dir
set tt=%time:~0,2%_%time:~3,2%_Backup
set folder=%date:/=-% %tt%
set backupcmd=xcopy /s /c /d /e /h /i /r /k /y
set Stuff2Backup=%USERPROFILE%\My Documents\


color 9F
echo ### Mindweaver's Backup Plain

%backupcmd% "%Stuff2Backup%\*.*" "%drive%\%folder%\%file%"


echo ### Setting Attribute's

attrib +r -h %drive%\* /s /d

echo This Backup was created on Date (%date%), Time (%time%). >> "%drive%\%folder%\Backuplog.txt"

echo Backup Complete!
@pause

EDIT: Sorry mods for double post.. My back is out of wack and i'm on muscle relaxers.. :p
 
No problem. I noticed something I missed last night while on the pain killers.. lol You'll need to put %USERPROFILE%\My Documents in "" like this "%USERPROFILE%\My Documents" and you'll want to remove the \ in front of Documents. I fixed the code above if you want to re-copy that code. :toast:

EDIT: The reason you need to put it in "" is because of the space in My Documents. The batch file will break at that point and tell you it can't find the location. :toast:
 
No problem. I noticed something I missed last night while on the pain killers.. lol You'll need to put %USERPROFILE%\My Documents in "" like this "%USERPROFILE%\My Documents" and you'll want to remove the \ in front of Documents. I fixed the code above if you want to re-copy that code. :toast:

EDIT: The reason you need to put it in "" is because of the space in My Documents. The batch file will break at that point and tell you it can't find the location. :toast:

sTILL not working..here's how it looks

@echo off
cls
echo Press Any Key to continue backup!
pause
xcopy /s /i d:\backups\Mozilla c:\mozillaback
copy . c:\%USERPROFILE%\My Documents d:\Backups\My Documents
echo Backup has now finnished !

says: the syntax of the command is incorrect.
it does the first back..(mozilla) fine...then again at my documents..it's f'd up.
This is the exact directory...maybe u can edit it for me?
c:\documents and settings\spear\my documents.
backing up to
D:\backups\mozilla

if you can script it for me so i won't fuk up again???
thanks mind!
 
just wondering my first command is xcopy and the next is copy ...
 
sTILL not working..here's how it looks

@echo off
cls
echo Press Any Key to continue backup!
pause
xcopy /s /i d:\backups\Mozilla c:\mozillaback
copy . c:\%USERPROFILE%\My Documents d:\Backups\My Documents
echo Backup has now finnished !

says: the syntax of the command is incorrect.
it does the first back..(mozilla) fine...then again at my documents..it's f'd up.
This is the exact directory...maybe u can edit it for me?
c:\documents and settings\spear\my documents.
backing up to
D:\backups\mozilla

if you can script it for me so i won't fuk up again???
thanks mind!

You got a few errors in line copy . c:\%USERPROFILE%\My Documents d:\Backups\My Documents. The first one is copy needs to be xcopy and you need to remove the "." and you don't need to put the drive letter in front of Variable %USERPROFILE%. The other 2 errors are the spaces in both My Documents. When ever you refer to a folder that has spaces in the name you need to add "". Example : xcopy "%USERPROFILE%\My Documents" "d:\Backups\My Documents".

Copy and replace what you have in your batch file with this.
Code:
@echo off
cls
echo Press Any Key to continue backup!
pause
xcopy /s /i d:\backups\Mozilla c:\mozillaback
xcopy /s /c /d /e /h /i /r /k /y "%USERPROFILE%\My Documents" "d:\Backups\My Documents"
echo Backup has now finished!
 
Ahhh, now i understand!
gonna put that new script in...now i know forever if there's any space use Quotes ""
.
And i'm gonna try it right now...hold on.

You got a few errors in line copy . c:\%USERPROFILE%\My Documents d:\Backups\My Documents. The first one is copy needs to be xcopy and you need to remove the "." and you don't need to put the drive letter in front of Variable %USERPROFILE%. The other 2 errors are the spaces in both My Documents. When ever you refer to a folder that has spaces in the name you need to add "". Example : xcopy "%USERPROFILE%\My Documents" "d:\Backups\My Documents".

Copy and replace what you have in your batch file with this.
Code:
@echo off
cls
echo Press Any Key to continue backup!
pause
xcopy /s /i d:\backups\Mozilla c:\mozillaback
xcopy /s /c /d /e /h /i /r /k /y "%USERPROFILE%\My Documents" "d:\Backups\My Documents"
echo Backup has now finished!
 
it worked! thanks!

Now i have to figure out why my documents folder is hidden on the D: drive....lol.

i can see it thru cmd prompt....but not in explorer.

I just un attribed it -a -h -r -s....still don't see in folder...

But thanks again for the code brother .....bless u!

lyndon

Ahhh, now i understand!
gonna put that new script in...now i know forever if there's any space use Quotes ""
.
And i'm gonna try it right now...hold on.
 
You could use robocopy and save yourself a lot of trouble.
It's one line in a batch file to do just about everything you want and it will only backup files that changed so you aren't running a full backup when you don't need it.
I use it to backup my fileservers at work.
The newer version (post-XP) will multi-thread the backup too.

Just a tip from yer Ol' Uncle Kreij
 
You could use robocopy and save yourself a lot of trouble.
It's one line in a batch file to do just about everything you want and it will only backup files that changed so you aren't running a full backup when you don't need it.
I use it to backup my fileservers at work.
The newer version (post-XP) will multi-thread the backup too.

Just a tip from yer Ol' Uncle Kreij

Yea robocopy is the shit.. hehehe I use it too. :toast:

it worked! thanks!

Now i have to figure out why my documents folder is hidden on the D: drive....lol.

i can see it thru cmd prompt....but not in explorer.

I just un attribed it -a -h -r -s....still don't see in folder...

But thanks again for the code brother .....bless u!

lyndon

No problem! Paste your code in here and I'll see why it's hiding your files. My code shouldn't hind any files.. I use it quite often.
 
Last edited:
Yea robocopy is the shit.. hehehe I use it too.

Yeah, the granular control over what determines when a file should be backed up (file attributes, tweaks, etc.), the ability to specify directories to not include, ability to write the backup anywhere (Mapped drive, USB drive, etc.) and the ability to write/append logs make it easily as good as a paid backup solution.
Someone wrote a GUI for it, but it was a bit lacking the last time I looked at it.

Note : Robocopy is not for the faint of heart. It has more switches and options than TMM has infractions.
 
Last edited:
Note : Robocopy is not for the faint of heart. It has more switches and options than TMM has infractions.

Hell yea! lol
 
i will search for it on a torrent site..
I do like working in dos, but yea, an incremental or differential backup is preferable for sure.

Thanks for the tip ...gonna go snatch that muthr now!



You could use robocopy and save yourself a lot of trouble.
It's one line in a batch file to do just about everything you want and it will only backup files that changed so you aren't running a full backup when you don't need it.
I use it to backup my fileservers at work.
The newer version (post-XP) will multi-thread the backup too.

Just a tip from yer Ol' Uncle Kreij
 
Robocopy is free from Microsoft. It comes with everything after XP and is a free download for XP.
 
i just did a search...and one guy says this:
RichCopy is a free utility that comes to us from Ken Tamaru of Microsoft.
Some people say richcopy is an improvement over robocopy. Guess i'll try both!

u ever hear of richcopy?


You could use robocopy and save yourself a lot of trouble.
It's one line in a batch file to do just about everything you want and it will only backup files that changed so you aren't running a full backup when you don't need it.
I use it to backup my fileservers at work.
The newer version (post-XP) will multi-thread the backup too.

Just a tip from yer Ol' Uncle Kreij
 
No, that is new to me. Researching now. Thanks for the info.

update : looks like Richcopy has a GUI but has some issues and is not supported by MS (like robocopy).
Not that you need support by MS, but I wonder how well problems/issues are dealt with if found.
 
Last edited:
They aren't, there hasn't been an update to richcopy in years, and it isn't perfect.

I used to use robocopy backup scripts for my backups, but I'm too old/lazy to write scripts for every backup so I just use FBackup now. Plus I like that FBackup will use the volume shadow copy, so files in use still get backed up, which robocopy won't do.
 
i uninstalled it...looks like i can only backup 1 dir. at a time.....F*k that!
lol.

The other one robocopy is crazy....alot of dos commands, ( i like dos) but it also installed some files i didn't liike... some extra processes that i hate using my meager 4 gb i have.

Maybe i'll go back to backupmagic. that will backup differential, incremental...and multiple dir's.

I was just wondering why my batchfile i tried didn't work...but i understand how it works...need quotes if there's a space in directory name.

so what'd u find out? about richcopy?

No, that is new to me. Researching now. Thanks for the info.

update : looks like Richcopy has a GUI but has some issues and is not supported by MS (like robocopy).
Not that you need support by MS, but I wonder how well problems/issues are dealt with if found.
 
cool....i will try that one out!
is it free?

They aren't, there hasn't been an update to richcopy in years, and it isn't perfect.

I used to use robocopy backup scripts for my backups, but I'm too old/lazy to write scripts for every backup so I just use FBackup now. Plus I like that FBackup will use the volume shadow copy, so files in use still get backed up, which robocopy won't do.
 
Yes, it is free.
 
Back
Top