BUTOZIP (Back Up to Zip) creates a compressed file, a zip file, containing a designated set of files you want to archive, i.e., back up. When you invoke BUTOZIP, you specify the target drive:\directory, e.g., E:\ARCHIVE, where you want the zip file to be placed. In the following text I'll typically use "directory" in place of "folder" (the standard Windows term), but mean the same thing.
BUTOZIP uniquely names the zip file by using a sequence number (a generation number), the creation date, and a userid. A separate sequence number counter is maintained for each Windows user. With this naming, new backups don't overlay previous backups in the target drive:\directory. This allows multiple generations of backups to exist in the directory and allows multiple users to share that directory. With this zip file naming convention, it is very easy to locate a specific backup. Here is how a group of such files might be named in a target directory, e.g., E:\ARCHIVE, shared by two users:
For example, Bob might execute BUTOZIP.BAT E:\ARCHIVE, where his BUTOZIP.BAT has been edited to back up these directories (and their subdirectories) and files: C:\MISCPROG, C:\USERS\BOB\WORK, C:\USERS\BOB\DOCUMENTS\LETTERS, C:\SAVE\RESUME.DOC, and D:\BOOKS\DRAFTS. This is data which Bob changes frequently and would really hate to lose. The total disk space taken up by this data is not particularly large, maybe a few hundred MB. Note that BUTOZIP is not intended to back up very large directories, such as you might have for music or photos. The result of Bob's execution of BUTOZIP is the creation of a new zip file in E:\ARCHIVE, which might be on an external hard drive or flash drive. Using the sample directory shown above, if Bob next ran BUTOZIP on 12/3/12, the new file will be named Bob_#1542__2012-12-03.zip.
To later access files that were backed up by BUTOZIP, see Accessing Files from a Backup. Essentially you just use File Explorer (previously called Windows Explorer) and some Windows built-in facilities to decompress the zip file. Standard Windows procedures can then be used to copy, print, etc., the data.
By setting up a Windows shortcut, you can make running BUTOZIP a single-click operation to archive hundreds or thousands of scattered files into a single, compressed, organized file. Run BUTOZIP as often as needed; all the zip files created (one per BUTOZIP invocation) will nicely coexist in the target directory. You can create multiple shortcuts, each going to a separate target directory, e.g., one on a hard drive and another on a flash drive. Additionally, you can have multiple copies of the BAT file, each with a different name, e.g., BU_WORK.BAT, BU_GAMES.BAT, etc., where each is edited to back up a different set of files if you want to keep the backups separate. Doing regular backups can also be automated via the Windows Task Scheduler.
To make most efficient use of the BUTOZIP, it helps if you have organized data along the lines described in Organizing Your Data To Simplify Backups (mainly just grouping the data into a few directories, but without including many extraneous files), although this organization is not required. More overview information can be found in the "Selective Backups" section of Tools for Making Backups. These references are sections of the jgkhome.name\PC_Info\PC-InetNotes.htm file.
BUTOZIP is usually run from a shortcut or from the Task Scheduler (see "How To Run BUTOZIP" below). However it can also be run from a command window. Here is the basic syntax, where [...] means any parameter within a set of brackets is optional.
BUTOZIP [destination [password]]
Note that it is possible to do stronger encryption, i.e., AES256. There is a note in the sample BUTOZIP.BAT file showing how to do that by adding the -mem=AES256 switch. However files encrypted this way cannot be unzipped by the built-in Windows tools. Instead you can use some 7-Zip facilities, which are easy to use, but are not covered here. See the 7-Zip documentation which is included in the 7-Zip download package. To do this more complicated unzipping, it would be a good idea to install the standard (also free) 7-Zip package in addition to the command line package that BUTOZIP requires. For example, the standard version adds a 7-Zip item to the right-click menu, which makes it easy to perform 7-Zip operations on a selected file.
Before starting to use BUTOZIP, you must do some setup. This has to be done only once.
You must create the directory before running BUTOZIP. It cannot be the root directory, i.e, F:\ in the example above. Precluding the root directory lessens the chance you might accidentally send the backup to the wrong device, e.g., if you have plugged in the wrong flash drive. BUTOZIP will detect unacceptable directories for this and other situations; it will issue an error message and abort before copying any files.
You can specify the target directory as an optional parameter when you invoke BUTOZIP.BAT, e.g., BUTOZIP.BAT F:\DAILYBACKUPS. If you run BUTOZIP without this parameter, the default target directory used by BUTOZIP is D:\BACKUPS.
Although the examples here use a single-level directory, and that is probably what most people will use, you can also specify a multi-level directory as the target, e.g., D:\SAVE\2012\BACKUPS.
The location and name for some Windows directories, e.g., Documents, differs from release to release of Windows, e.g., Windows XP vs. Windows 7. For some directories in some releases, the name required by XCOPY ("Documents") actually differs from the name displayed by Explorer ("My Documents"). A similar thing applies to My Music, My Pictures, etc. This may be dependent on which release or even edition of Windows is involved; you will need to experiment to see what applies for your system. Fortunately the "My" naming confusion seems to have been eliminated in the later Windows releases, e.g., Windows 10. In any event, you will also need to experiment to find where your applications bury their critical data so you can back it up. Unfortunately some applications may make this more difficult than it should be.
BUTOZIP uses the Windows XCOPY command to copy files. Information about this command is in the table below and in notes in the BAT file. The best idea would be to just use as a model the XCOPY commands in the sample BUTOZIP.BAT; the notes and XCOPY commands are near the bottom of the BAT file, surrounded by comment lines of $$$$$$$$$s. The name of the directory you copy to need not be the same as what you are copying from. This may help you put your backup in a simpler, more meaningful structure than the structure(s) it came from.
You don't have to list all the subdirectories; just list the master directories containing the subdirectories of interest and use the XCOPY /S option to copy the whole directory tree. (That's in fact why you should organize your data as described in Organizing Your Data To Simplify Backups.) You can also list individual files if they are not easily put into your master directories organization. For each directory copied, you can specify the name the copy will have in the backup; thus Windows' very long directory names can be shortened, if desired.
XCOPY cannot copy a locked file, a file opened for exclusive use by some process. If you want to use BUTOZIP to back up such files, you should close them first. If you forget to do so, the associated XCOPY will fail and issue an error message, such as "Sharing violation". Before running BUTOZIP I sometimes forget to close Thunderbird, which has some locked files. To make the XCOPY failure reason obvious, I put logic in BUTOZIP warning me to close Thunderbird and then rerun BUTOZIP. If you have similar files, you might include and modify that code.
The BAT file can be invoked in a number of ways. Here are a few:
If the backup completes successfully, BUTOZIP will display the main report file as its final output in the command window, below all the displayed XCOPY commands. This report normally consists of a number of "xx File(s) copied" lines, one for each XCOPY you had in the BAT file, and a "******* COPY TO TARGET DIRECTORY WAS SUCCESSFUL! *******" if BUTOZIP found no errors. There will also be some lines with timestamps taken at major points in the operation, as well as a display of some key variables. If an error was detected, either Windows or BUTOZIP should report it and then abort the operation. A successful run should produce something similar to this as the final output:
====================================================================== BUTOZIP version 1.7 report on Thu 10/08/2019 ---------------------------------------------------------- 6:00:00.17 21 File(s) copied 310 File(s) copied 1525 File(s) copied 181 File(s) copied 144 File(s) copied 4 File(s) copied 1 File(s) copied 2 File(s) copied 1 File(s) copied 198 File(s) copied ---------------------------------------------------------- 6:00:14.93 Target directory for zip file: X:\BACKUPS Backup: #2771 ******* COPY TO TARGET DIRECTORY WAS SUCCESSFUL! ******* C:\BUTOZIP_TEMP\Jeff_#2771__2015-08-10.zip to X:\BACKUPS ---------------------------------------------------------- 6:00:35.07 Zip file size: 107,341,354 ))))))) 104,826 KB ((((((( ---------------------------------------------------------- 6:00:36.42
CAUTION: If the BAT file cannot complete successfully, e.g., if there is not enough space on the destination medium to hold the zip file, BUTOZIP will abort, either automatically or as a result of your response to a prompt. Then you must do a manual cleanup of the work directory and the target directory. (You can just delete the whole work directory after looking at the contents; it will be rebuilt the next time BUTOZIP is run.) The TDIR subdirectory and zip file in the work directory can be very large and serve no purpose after the BAT file exits. It is not good to leave them around if the BAT file did not erase them.
NOTE: Color capability has now been added to BUTOZIP, e.g., to display a different background color in the command window if an error has been detected vs. if BUTOZIP completed successfully. If you don't like the colors used, you can change the @COLOR commands when you edit the BAT file.
The following table lists some key variables used by BUTOZIP. You probably will not need to change any of them. (As noted above, the main tailoring you must do to BUTOZIP.BAT is setting up the XCOPY commands.) This table shows you the main components used to construct the zip file name. Knowing the name structure will help you use the backups most effectively. Details are in the How It Works section below.
|environment variable||default value
|ZIP||C:\JGK\7ZIP\7ZA.EXE||ZIP specifies the location and name of the 7-Zip command line program, 7za.exe. This program can be downloaded from here. For example it is in the "7-Zip Command Line Version" zip file. (The 32-bit program works fine on both 32-bit and 64-bit PCs.) Unzip the file, placing the contents into the directory named by the front part of the ZIP variable, e.g., in the C:\JGK\7ZIP directory in this case. If you want to use a different name for this directory, you can do so; be sure to modify this SET variable to match.|
|BUTARGET||D:\BACKUPS||You intend for the zip file created by BUTOZIP to end up in a specific drive:\directory. The BUTARGET variable names the default target drive:\directory. If this default target location is not what you want, you can override it by invoking BUTOZIP.BAT with a parameter, e.g., BUTOZIP.BAT F:\DAILYBACKUPS. In any event, the chosen target drive:\directory must already exist before BUTOZIP.BAT is run.|
|BUWORK||C:\BUTOZIP_TEMP||BUWORK specifies the name of a hard drive directory that can be used as a work area. It should be on a hard drive for speed. The user running BUTOZIP must have full access to the directory contents (read/write/create/erase). This is where the zip file will be built initially before it is moved to its final destination. The BAT file creates this directory if it does not already exist. If the default of C:\BUTOZIP_TEMP is not appropriate for your PC, modify the SET to specify another location.|
|UNAME||%USERNAME%||The %USERNAME% setting for UNAME will resolve to the name of the user running BUTOZIP. That is, it is the user name for the Windows PC account under which the BAT file is run. If multiple users share the PC, using different accounts, they can all make backups in the same target directory. A user name will be made part of each zip file's name, allowing each file to be associated with the proper user.|
|BUPWD||(null, i.e., no password)||If specified, the password must be the second command parameter, i.e., a drive must be specified as the first parameter. The password is passed to 7-Zip to encrypt the zip file and must be acceptable to 7-Zip. If no password is specified, the zip file is not encrypted.|
|XCOPY commands specify the names of
the directories and files to be archived, as well as the names
to be given to the copied data. Options can be used to say
whether a whole directory tree should be copied (/S) and
whether hidden files (/H) and empty directories (/E) are to be
copied. Output messages are directed to a report file. The /Q
option suppresses some unneeded XCOPY messages.
The general command format is:
XCOPY from-data to-data
options >> report-file 2>&1
CAUTION: If any directory or file names (including parts of the TDIR directory name described below) contain blanks (spaces), be sure to surround the full names with quotes in the XCOPYs. That is the standard Windows requirement for such names when used in a command. For example:
XCOPY "C:\LONG SPACED NAME\*.*" "%TDIR%\MISC\*.*" /S /H /Q >> %BUREPORT% 2>&1
An unencrypted zip file is created in D:\BACKUPS, the default directory.
An unencrypted zip file is created in F:\FINANCIALS.
BUTOZIP E:\DRAFTS tyb4u3ldwrRH
An encrypted zip file is created in E:\DRAFTS using tyb4u3ldwrRH as the password.
BUTOZIP D:\BACKUPS qlGy59apx
An encrypted zip file is created in D:\BACKUPS using qlGy59apx as the password. Even though D:\BACKUPS is the default directory, it still must be specified since the password must be the second parameter.
Here is the basic logic flow. The most important actions are echoed to the display while the BAT file is running.
At some point after you have created a backup zip file, you may want to recover files from it. The 7-Zip tool has facilities to do this, which won't be covered here. However Windows has built-in facilities that can do the job. You can do some simple doubleclicking (multiple times) to get to the files in Windows "compressed folder" mode. There you can view the files, but there are limited things you can do with them in that mode, e.g., not all programs will execute properly. Note you can copy a file or files from the "compressed folder" to a normal folder, which will not have the "compressed folder" restrictions.
Alternatively, you can do some mouse right-clicking on the zip file and select "Extract All" from the menu (maybe multiple times") to completely unzip the files into a standard folder (directory) of your choosing. There things act more normally.
If you specified a password to encrypt the zip file, along the way you will be prompted to enter the password. Also, if you used encryption, there will be an additional doubleclick required because the original data was zipped twice, once to create the original zip file and then again to encrypt that file.
In more detail, to unzip an encrypted zip file into a "compressed folder":
You may then have to wait a few seconds (depending on the archive size and contents) as the decryption is done. Be patient. Once the hour glass (or similar wait indicator, if any) disappears, the archive contents are displayed as a folder with the original zip file name, but without the ".zip" extension and zipper on the folder icon.
If the zip file had not been encrypted, no password prompt occurs and there is one fewer doubleclicks required. In general, just keep doubleclicking until the backed-up files are displayed in the "compressed folder".
Doing an extract to a normal directory (folder) is similar. Just keep right-clicking and selecting "Extract All" on the output until "Extract All" is no longer in the right-click menu. Then you can instead doubleclick that final directory to see the backed-up files in a normal directory. If encryption had been done on the original zip file, you will be prompted for a password after selecting the first "Extract All".
Here are the main changes to date for the BUTOZIP.BAT file and this Overview file.