It is a good idea to use WinRAR to compress the data before backing up the data. This has at least the following advantages:
1. Save space. This depends on the nature of the source file. Generally speaking, text-type office documents compression ratio is higher, while multimedia files compression effect is often not obvious.
2. Accelerate the copying speed. Backup files often need to be copied to N different locations/storage media. Even if the file size does not change much after compression, it is best to compress it in the "storage method", because under the same size, large single files are copied faster than many scattered files.
3. Keep it confidential. The file can be encrypted using a compressed password.
However, it is really troublesome to right-click the file/folder every time and then set the password. Fortunately, WinRAR supports command line mode, and we can compile a batch file to help us back up.
The command line format of WinRAR is as follows:
"E:\Program Files\WinRAR\" a switch The generated compressed file path and name Source file path and name
illustrate:
"E:\Program Files\WinRAR\" is the location where WinRAR is located. If the path on your computer is in another folder, please make corresponding changes.
a: This is a command, a is the "add" command, which means adding a file to a compressed file. No matter it, if you want to compress it, bring a with you.
Switch: The switch is immediately followed by the command. You can add many switches and make them casually according to your own preferences. Let’s take a look at two simple ones, and if necessary, just put them directly after the command:
-sfx �
-ibck
It is recommended to add -ibck to let WinRAR hide in the background and compress slowly, and don’t sway in front of us, which is upset. This has no effect on compression quality, it only affects our mood.
Let’s look at two more complicated ones, saying that they are complicated just because the parameters can be followed:
-m �
-p �
-m: This switch is used to control the storage method, that is, the compression method. If this switch is not added, the default is the standard compression method. There are six storage methods, from 0 to 5, the compression rate is getting bigger and bigger, and the compression speed is getting slower and slower. You can choose according to the nature of the compressed file. For example: the file compression rate is not high, only 99%, so you can choose 0 storage method to save time. If you want to choose 4 (a better storage method), then the switch is: -m4, other analogies
-p: This can add a password to the compressed file, just follow the password, such as: -p123, the password of this file is 123.
Okay, let's take a look at an example and try to see if you can understand:
"E:\Program Files\WinRAR\" a –ibck –m5 –pmima f:\target.rar e:\source
Note: In WinRAR's command format, the source file should be placed behind the target. This regulation is awkward, but we can do nothing, just be careful.
The meaning of this example is to compress the "source" folder under the e disk in the optimal compression method, generate the "target.rar" file on the f disk, set the password to "mima", and compress it in the background. If you want to generate a compressed file in self-decompression format, add the -sfx parameter.
However, this cannot be really applied to normal backups, because during the second compression, we must first delete the first backup, so we need to add the command to delete the old file (the third line below):
@echo off
Color a9
Del f:\target.rar
"E:\Program Files\WinRAR\" a –ibck –m5 –p password set by yourself f:\target.rar e:\source
Pause
Copy the above command to Notepad, set the command switch, then replace the target and source with your own file, save as a "compressed .bat" file (the name is casually named, but .bat cannot be changed), and double-click to run to complete the backup.
For more commands and switches on the WinRAR command line, you can search in the WinRAR help file