Automate your daily backups (example 1)
Many people think about daily backups only after losing their data due to a hard drive failure or a foolish mistake. Personally, I chose to use 7-Zip for my simple backup scenarios. 7-Zip is an open-source file archiver with a high compression ratio. It is very flexible and all of its features can be accessed from the command line.
The command line version of 7-Zip is great for using in batch scripts. To simplify the backup process, you can also create inclusion and exclusion lists of files and directories that you want to backup.
You can write a command line that looks like this:
/TITLE="7-Zip Backup" /MSG="Backup is completed successfully!"
/ERRMSG="An error occurred while backing up data."
""C:\Program Files\7-Zip\7z.exe" a -tzip backup.zip
-i@backup_list.txt -xr@exclude_list.txt"
After the backup process is finished (note the /WAIT switch), a simple message is displayed telling you that everything is OK:
Once you setup a repeatable backup process in Task Scheduler, you only needed to modify your inclusion list to add new files to the backup (note that 7-Zip uses UTF-8 encoding for list files by default).
Here is a simple example of an exclusion list. It can be used to exclude some unnecessary files when making a backup copy of a Visual Studio project directory:
Using another command or batch file, you can upload the resulting archive to an external storage (home file server or external hard drive).
The sample files are also included in the Hstart package (see Examples\Backup).
Download Hstart (32-bit and 64-bit)
Related Links
7-Zip tutorials:
Hstart examples:
- Example 1: Automate your daily backups
- Example 2: Optimize images with PNGOUT
- Example 3: Code Signing with one click
* All screenshots on this page are made with WinSnap.
