Using 7zip command line to backup files/folders

I wanted a simple tool to backup my system. Although Windows provide a backup tool that was too much for me and I wanted flexibility in file storage and archiving.

I wrote a quick script to achieve this job. I used Robocopy to copy and aggregate all required files in a single drive. Finally I used 7zip command line tool to create a compressed zip file. Actually, multiple compressed zip files in increments on 1GB. Since I was uploading the files I wanted the size to not be more than 1GB (hosting provider limitation).

Here is the sample 7zip command:

7za.exe a -i!d: -x!*.zip -x!*.mdf -x!*.ldf -x!d:$recycle.bin -x!"System Volume Information" -r -v 900

7za is the command line tool for 7zip and is available along with the standard 7zip download. Paramater “a” indicates we want to create a new compressed archive. Next parameter specifies the backup file name.

-i option is used to include files or folders, -x to exclude files and folders
-r to recursively process sub-directories
-v to split the compressed file into chunks. 900 specifies the max file size – in this case 900MB.If -v is used, the generated files will have incremental extensions like .001, .002, .003, etc

Full command line usage can be found at

Leave a Reply

Your email address will not be published. Required fields are marked *