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



## GraveFiller (Nov 15, 2012)

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.
!


----------



## eidairaman1 (Nov 15, 2012)

Because My Documents isnt My Documents anymore. You have to point at the specific directory of the account your backing up


----------



## Mindweaver (Nov 15, 2012)

Try using "_%USERPROFILE%\My Documents_". 

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


----------



## Mindweaver (Nov 15, 2012)

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! 

Remember to set the path for the following

set drive=*u:\Backup_Dir*
set Stuff2Backup=*%USERPROFILE%\Documents*


```
@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.. *


----------



## GraveFiller (Nov 15, 2012)

Mindweaver said:


> Try using "_%USERPROFILE%\My Documents_".
> 
> *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!


----------



## GraveFiller (Nov 15, 2012)

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!




Mindweaver said:


> 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!
> 
> Remember to set the path for the following
> 
> ...


----------



## Mindweaver (Nov 15, 2012)

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. 

*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. *


----------



## GraveFiller (Nov 15, 2012)

Mindweaver said:


> 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.
> 
> *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. *



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!


----------



## PopcornMachine (Nov 15, 2012)

just wondering my first command is xcopy and the next is copy ...


----------



## Mindweaver (Nov 16, 2012)

GraveFiller said:


> sTILL  not working..here's how it looks
> 
> @echo off
> cls
> ...



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. 

```
@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!
```


----------



## GraveFiller (Nov 16, 2012)

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.



Mindweaver said:


> 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.
> 
> ...


----------



## GraveFiller (Nov 16, 2012)

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



GraveFiller said:


> 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.


----------



## Kreij (Nov 16, 2012)

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


----------



## Mindweaver (Nov 17, 2012)

Kreij said:


> 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.
> ...



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



GraveFiller said:


> it worked!  thanks!
> 
> Now i have to figure out why my documents folder is hidden on the D: drive....lol.
> 
> ...



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.


----------



## Kreij (Nov 17, 2012)

Mindweaver said:


> 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._


----------



## Mindweaver (Nov 17, 2012)

Kreij said:


> _Note : Robocopy is not for the faint of heart. It has more switches and options than TMM has infractions._



Hell yea! lol


----------



## GraveFiller (Nov 17, 2012)

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!





Kreij said:


> 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.
> ...


----------



## Kreij (Nov 17, 2012)

Robocopy is free from Microsoft. It comes with everything after XP and is a free download for XP.


----------



## GraveFiller (Nov 17, 2012)

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?  




Kreij said:


> 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.
> ...


----------



## Kreij (Nov 17, 2012)

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.


----------



## newtekie1 (Nov 17, 2012)

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.


----------



## GraveFiller (Nov 19, 2012)

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?



Kreij said:


> 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.


----------



## GraveFiller (Nov 19, 2012)

cool....i will try that one out!
is it free?



newtekie1 said:


> 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.


----------



## newtekie1 (Nov 19, 2012)

Yes, it is free.


----------

