On 8/11/2011 05:40, M.L. wrote:
>
> I need a backup script that allows me to backup the Documents, Desktop
> and Favorites folders for each account on a Vista/Win 7 system
> (assuming they use the same directory paths). If possible, I'd like it
> to be usable for XP. Otherwise I'd like tips on modifying the script
> to be used for a separate XP script.
>
> The restore process could be either a flag within the backup script
> that performs the same process by reversing the output directories, or
> it could simply be a separate script altogether.
> I'd like to use it as a one-time backup/restore before reinstalling
> Windows on a single self-contained computer,
Batch files are helpful for recurring tasks, and complicated once-off tasks.
Your backup task is a once-off file copy, with backup permissions, and isn't really suited for a batch file where you have to write it and test it to see if it functions correctly - and then throw it away.
If you want to go ahead, you need to parse the user list folder, and reject the standard system folders, and then xcopy from the rest of the user folders after prepending the user name. You will probably also need to run under an account with backup permissions.
This is something I had squirreled away - the tests will need to be changed from NT to Win7 and the copy destination/target changed, and some logic to ignore the system folders.
I don't think it is tested.
@echo off
:: reads serverlist.txt - one server\share per line in \\mypc\c format
:: copies non-hidden/system favorites from
:: c:\windows\profiles\user\favorites\
:: and
:: c:\Documents and Settings\user\favorites\
:: to the local drive, and recreates the folder structure
:: using the c:\server\share\ as the container for that machines items.
:: IE: for \\mypc\c it will place all favorites in c:\mypc\c\windows\blah blah\
:: additionally will read extlist.txt and copies all files matching the filespecs
:: one filespec per line
:: into the \\server\share container, maintaining folder structure.
for /f "delims=" %%z in (serverlist.txt) do (
echo server "%%~dpz"
if exist "%%~dpz\windows\profiles\" (
echo NT
for /f "delims=" %%a in ('dir "%%~dpz\windows\profiles\" /b /ad') do (
for /f "delims=" %%b in ('dir "%%~dpz\windows\profiles\%%a\favorites\" /b /ad') do (
xcopy /x /h /e /r /k /f /c "%%~dpz\windows\profiles\%%a\favorites\%%b" "C:\%%~pz\windows\profiles\%%a\favorites\%%b\")
)
)
if exist "%%~dpz\Documents and Settings\" (
echo W2K/XP
for /f "delims=" %%a in ('dir "%%~dpz\Documents and Settings\" /b /ad') do (
for /f "delims=" %%b in ('dir "%%~dpz\Documents and Settings\%%a\favorites\" /b /ad') do (
xcopy /x /h /e /r /k /f /c "%%~dpz\Documents and Settings\%%a\favorites\%%b" "C:\%%~pz\Documents and Settings\%%a\favorites\%%b\")
)
)
for /f "delims=" %%a in (extlist.txt) do (
for /f "delims=" %%b in ('dir "%%~dpz\%%a" /b /s /a-d') do (
xcopy /x /h /r /k /f /c "%%b" "c:\%%~pb")
)
)
--
Regards,
Mic