how to backup on a drive connected to wireless router

Dannypje

Honorable
Dec 27, 2013
4
0
10,510
SITUATION
=========
I am using a PC with windows Vista (home edition).
I recently bought a Toshiba 500GB external USB hard disk, which I connected to my Sitecom X6 N900 router. The router has 2 USB ports that can be configured to support samba devices.
So I assigned drive letter Z to the disk connected to the router, so it is now known as a network drive and can be seen by each PC on the network.
I want to use this network drive for automated backups, so I wrote a batch file (see below) to perform this backup. The batch file resides on the PC(s), so these PCs 'push' their data towards the samba drive. The alternative could be to place the batch file on the network drive and start it up from there ('pulling' the data in from the PCs to the network drive, but this would require me to identify in the batch file the PC from which the backup is to be taken, which I don't know how to do, nor do I want to do that as this requires me to know which PCs are all connected to the network, so the 'push' option seems to be the way to go).

THE BATCH FILE
==============
xcopy c:\users\Danny\DataD\*.* z:\data\backup\DataD /e/y/d/EXCLUDE:c:\users\Danny\excluderfile.txt > c:\users\Danny\bulog.txt
xcopy c:\users\Elien\DataE\*.* z:\data\backup\DataE /e/y/d/EXCLUDE:c:\users\Danny\excluderfile.txt >> c:\users\Danny\bulog.txt
xcopy c:\users\Wouter\DataW\*.* z:\data\backup\DataW /e/y/d/EXCLUDE:c:\users\Danny\excluderfile.txt >> c:\users\Danny\bulog.txt
xcopy c:\users\Lieve\DataL\*.* z:\data\backup\DataL /e/y/d/EXCLUDE:c:\users\Danny\excluderfile.txt >> c:\users\Danny\bulog.txt
copy c:\users\Danny\buz.bat z:\data\backup
copy c:\users\Danny\excluderfile.txt z:\data\backup
@echo off
echo %date% > c:\users\Danny\budate.txt
type c:\users\Danny\bulog.txt
set/p re="Please confirm exit ==> "
exit

PROBLEM
=======
When running the batch file, it fails because it seems not to be allowed to create the necessary (sub)folders for the backup. For example, the first subfolder under DataD is 'Afbeeldingen' and the system does not allow the batch file to create this folder.

TRIALS AND OBSERVATIONS
=======================
I'm running this batch file from the 'Danny' user, which is the administrator of this PC.
Copying files directly without creating (sub)folder (see the 2 copy commands in the batch file) does work, even through the batch file ! So I have the impression it's really about the batch file not having permissions to create subfolders (though as far as I can see, all permissions are granted to the batch file).
When connecting the drive directly to my PC, and changing the drive letter z in the batch file to whatever letter the USB disk is connected under, the batch file works!
Creating folders manually on the network drive (meaning USB drive connected to router) from within windows works, as well as creating folders through a DOS box (mkdir command)!
Running the batch file from a DOS box does not work (error = fault during creation of file, access to network denied, cannot create folder).
Running the batch file from a DOS box started as administrator does not work (results in same error as above)
Running the batch file from windows as administrator does not work (results in same error as above)
The folders on the hard disk show read-only selected when requesting the property of the folder (same whether disk is connected directly to PC or to router). Setting the registry StorageDevicePolicies WriteProtect to 0 (as suggested in forums when people complain their USB disk folders are write protected) does not help. Re-formatting the hard disk (as also suggested), did not help either.
When requesting the properties of the hard disk, while connected directly to PC, file system shows as NTFS, however, when requesting properties of disk connected as network drive to router, file system shows as FAT32. I wonder if the router is only capable of dealing with FAT/FAT32 formatted devices (mail sent to sitecom to ask, no reply yet), however given the fact that this is a recent router, that would be stupid.
Upgraded router firmware to version 2.9, which contained some improvement for samba server, but no change.
When disconnecting disk from router (after breaking connection via windows), router needs a reset when disk is reconnected, otherwise sambaport of router is not shown when trying to re-map the drive (which has me wondering about the quality of the sambaserver software on the router).
Another thing I tried is setting the EnableLinkedConnections to 1 in the HKEYLOCALMACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Policies/System folder.
Formatting the USB disk in FAT32 is at this moment one step too far, which I'm not yet willing to take, as manual folder creation does work.

Any advice is appreciated.

Danny
 
Solution
User account control could be your issue.
Even though your user is an administrator, they don't automatically have administrator privileges.
Start -> Search programs and files
Enter "cmd"
Right hand click on the command prompt entry that appears and select "Run as administrator".
Run the batch file from within this command prompt.
When running this as a task, you should be able to force this by modifying the properties of the batch file.

Try using * rather than *.* in your xcopy commands.

Try robocopy instead of xcopy as it is a lot more reliable.
Robocopy is also installed with Windows.
Replace:
xcopy c:\users\Danny\DataD\*.* z:\data\backup\DataD /e/y/d/EXCLUDE:c:\users\Danny\excluderfile.txt > c:\users\Danny\bulog.txt
with this...
User account control could be your issue.
Even though your user is an administrator, they don't automatically have administrator privileges.
Start -> Search programs and files
Enter "cmd"
Right hand click on the command prompt entry that appears and select "Run as administrator".
Run the batch file from within this command prompt.
When running this as a task, you should be able to force this by modifying the properties of the batch file.

Try using * rather than *.* in your xcopy commands.

Try robocopy instead of xcopy as it is a lot more reliable.
Robocopy is also installed with Windows.
Replace:
xcopy c:\users\Danny\DataD\*.* z:\data\backup\DataD /e/y/d/EXCLUDE:c:\users\Danny\excluderfile.txt > c:\users\Danny\bulog.txt
with this:
robocopy c:\users\Danny\DataD z:\data\backup\DataD /E /XF c:\users\Danny\excluderfile.txt > c:\users\Danny\bulog.txt

Note that you can replace /E with /MIR if you want to delete files in the destination directory that have been deleted from the source directory.
 
Solution

Dannypje

Honorable
Dec 27, 2013
4
0
10,510
Vincent,

I already tried running the batch file both as an administrator as well as from a DOS command prompt started as administrator. Did not help.

However, your proposal to use robocopy instead of xcopy works like a charm !! Thanks a lot for your help !

PS: the excluderfile.txt that I'm using contains a list of directories and files that I don't want to be part of the backup. I am now testing that out the way you indicated. Is robocopy able to read such files to exclude the paths/files in them ?
 


I don't think this is an option they implement.
Use /XF to exclude listed files or /XD to exclude listed directories.
 

Dannypje

Honorable
Dec 27, 2013
4
0
10,510


Indeed, using a file doesn't work, will use /XF and /XD. thx.