1
votes

I am creating a small backup script for my personal use, and it works at 99% on the latest version of 7zip, Win7x64 :

:: u : Update archive

:: -t7z : Use 7z file type (less compatible and smaller results)

:: -mx=9 : "Ultra" compression

:: -ms=off : Do not create solid archive (they are incompatible with update archive mode)

:: -mmt=off : Enable multithreading

:: -r : Recursive (traverse all subdirectories)

:: -ssw : Compress locked files

:: -w : Working dir to G: drive (no temp file copy from disk to disk)

@echo "%userprofile%\Desktop" >> list.txt

@echo "%userprofile%\Documents" >> list.txt

@echo "%userprofile%\Downloads" >> list.txt

@echo "%userprofile%\Saved Games" >> list.txt

@echo "%userprofile%\Pictures" >> list.txt

"C:\Program Files (x86)\7-Zip\7z.exe" u -t7z -mx=9 -ms=off -mmt=on -r -ssw -wg: "G:\AutoSaveC\SaveC.7z" @list.txt

del list.txt

shutdown -s -t 180

There are two problems tho :

1- Even though the archive contains all expected folders and files, it also contains stuff never intended to be there (only part of the files from the original folders) :

%userprofile%\AppData

%userprofile%\Music

2- It also gives me warnings about denied access to folders I NEVER told it to look at :

C:\Users\LocalAdmin\AppData\Local\Application Data\: WARNING: Access denied. C:\Users\LocalAdmin\AppData\Local\ElevatedDiagnostics\: WARNING: Access denied. C:\Users\LocalAdmin\AppData\Local\History\: WARNING: Access denied. C:\Users\LocalAdmin\AppData\Local\Temp\msdtadmin\: WARNING: Access denied. C:\Users\LocalAdmin\AppData\Local\Temporary Internet Files\: WARNING: Access denied. C:\Users\LocalAdmin\Application Data\: WARNING: Access denied. C:\Users\LocalAdmin\Cookies\: WARNING: Access denied. C:\Users\LocalAdmin\Local Settings\: WARNING: Access denied. C:\Users\LocalAdmin\Recent\: WARNING: Access denied. C:\Users\LocalAdmin\SendTo\: WARNING: Access denied.

Do you know what I'm doing wrong ? Or is it a bug from 7zip ?

2

2 Answers

2
votes

Consider that there may be soft links to files in those directories. The Users folder in particular is filled with virtual paths. There are paths in there that exist solely to redirect older applications that still use them to the proper location.

1
votes

Instead of echoing the contents of the directory the way you are doing it, why not redirect the output of DIR to your text file instead? This way, you can filter out hidden files, .lnk files, system files, and many other options for file filtering are at your disposal. For instance, to weed out hidden, system, and .lnk files:

DIR "%userprofile%\Desktop" /b /s /a:-h-s | FIND /v "*.lnk">>"C:\some\file.txt"

the /b switch will return only the filename.ext, the /s switch returns all files in said directory AND subdirectories, and the /a:-hs switch removes all hidden and system files. Then of course FIND /v means to find all files NOT containing the following string.