Automating the daily Backup of My Documents folder

Abdul Haq

Junior Member
May 25, 2016
4
0
0
Greetings,

In my previous organization when we were using WindowsXP an autoexec.bat file will be triggered every morning when we powered on our desktops and it will backup all the modified files in our My Documents directory to a backup server on the network. This was a life-saver in the event of any hard disk failure of any user in the organization. I would like to do the same for my new organization (I am an IT Auditor) where we use Windows 7. I understand that Windows 7 does not support Autoexec.bat file like the previous versions. I request you to guide me backup the My Documents folder every morning by using command prompt, copy, robocopy and/or powershell. This help will be greatly appreciated.

I created a script with robocopy and I used Task Schedular to run this script when the computer starts. It works fine for backing up a folder from the root of the C:Drive. However this does not work for backing up the My Documents folder where it requires administration privileges. I am logged in as a standard user and I can run this bat file only as an administrator. When I power on the computer as an administrator this works but fails when I log in as a standard user. All the staff are standard users and kindly help me to run this batch file at startup for a standard user.


Regards,

Abdul Haq
 

yinan

Golden Member
Jan 12, 2007
1,801
2
71
You really should just look into folder redirection with Group Policy
 

tcsenter

Lifer
Sep 7, 2001
18,884
524
126
Microsoft SyncToy or Karen's Replicator. See also: Microsoft OneDrive or other free online backup/storage. Not sure why you would do the backup first thing in the morning rather than at the end of each workday. That leaves the entire night or entire weekend for something to happen.
 
Feb 25, 2011
16,991
1,620
126
Given what you've already got going, seems like the simple ways (using what you already know and not having to install additional programs) are:

Option 1) Use multiple BAT files running as different users.
Option 2) Use Windows Backup Utility instead.
Option 3) Run the scheduled task as the SYSTEM user so it can do ANYTHING to ANYTHING.
 

tcsenter

Lifer
Sep 7, 2001
18,884
524
126
BTW, Windows 7 32-bit should still support some of these legacy interfaces and shells. It is 64-bit version that has removed many or won't run. Have you tried it straight away or running in compatibility mode (with admin privileges) for XP?
 

sm625

Diamond Member
May 6, 2011
8,172
137
106
Code:
IF NOT EXIST H:\test.txt ECHO Cannot access server.
IF NOT EXIST H:\test.txt ECHO Try again later.
IF NOT EXIST H:\test.txt PAUSE
IF NOT EXIST H:\test.txt GOTO END

C:
cd %UserProfile%\documents


xcopy *.* H:\MyDocuments /d /e /y /v /c

pause

:END

Paste this into a batch file and then place a shortcut to this batch file into your startup folder. This batch file assumes that H: is your backup server path. You will need to create an empty file called test.txt which is used to ensure the connection is up.
 

Abdul Haq

Junior Member
May 25, 2016
4
0
0
Or another option would be something like Veeam endpoint backup which is free.
https://www.veeam.com/endpoint-backup-free.html

Might also help if you actually posted the script you're using.

The actual script is as follows:

rem "Backing up My Documents"
robocopy C:\Users\user\Documents\ //PC-PC/SHARED_FOLDER /e /z /xo /np /tee /mt:4 /xa:h /r:10 /w:10 /XF /LOG://PC-PC/SHARED_FOLDER\Backup.log
pause
 
Last edited:

BonzaiDuck

Lifer
Jun 30, 2004
16,307
1,878
126
Code:
IF NOT EXIST H:\test.txt ECHO Cannot access server.
IF NOT EXIST H:\test.txt ECHO Try again later.
IF NOT EXIST H:\test.txt PAUSE
IF NOT EXIST H:\test.txt GOTO END
 
C:
cd %UserProfile%\documents
 
 
xcopy *.* H:\MyDocuments /d /e /y /v /c
 
pause
 
:END

Paste this into a batch file and then place a shortcut to this batch file into your startup folder. This batch file assumes that H: is your backup server path. You will need to create an empty file called test.txt which is used to ensure the connection is up.

I like this solution best of all. You can run ROBOCOPY or RichCopy 4.0, which provides a GUI, and you can schedule those things.

But scheduling a DOS-era command sequence in a batch file? Priceless.

I'd find it interesting to know the costs, scheduling difficulties and other factors for complete workstation backups in an office environment like the OP's, number of workstations, expected storage requirements. Would it even be possible to do those sorts of comprehensive backups nightly, such as I've set up to occur automatically with my own server and five workstations?

I think it would be wise to target important work files for the most frequent backups. As a sort of evolutionary process with little connection to the OP's office environment, I've come to do that sort of thing in addition to the nightly backups. For a business, you would certainly want to make nightly backups of those files, or schedule them for the morning boot-up.

Is there some policy about allowing employees to sleep and hibernate their computers?
 

nerp

Diamond Member
Dec 31, 2005
9,865
105
106
SyncToy would be so much easier. Then set up a scheduled task. Done and done.