ColdFusion in Baltimore Rotating Header Image

June, 2016:

Scheduled and encrypted backup of many files to Google Drive using 7zip, command line, and task scheduler, on Windows

Do you want to backup all or select documents to Google Drive, automatically, and optionally on a schedule? I use this for all my documents, including my CF websites.

This simple command line batch script will first compress and encrypt your files into a single archive file (backup.7z), then automatically upload it to Google Drive – on your schedule. I’m writing this for beginners so skip to the scripts if you know all this.


  1. Google Drive has a 15GB limit so your final compressed archive file cannot exceed that. But, 7zip will compress your files by a lot.
  2. This is for making a single file archive of all your files in case of disaster. You won’t be able to update a file at a time then upload those individually with this.
  3. If you have very large archive file and very slow internet (gasp!) it will take a long time to upload the archive. If you do not have broadband internet, this is not for you.
  4. You cannot backup your entire system with this, since most Windows systems are more than 15GB.

Enough talk, let’s get started:

  1. Download and install Google drive , start the program, and login to your account.
  2. Download and install 7zip, a free utility that will compress and encrypt your files.
  3. Create 3 files in your “My Documents” folder named as below and with the following content. You can edit as you see fit if you know how. I’ll explain what the content means.


This file contains the excludes list from your backup. These can be file(s) or folder(s). You can use wildcards, e.g. “*Pictures*” will exclude “My Pictures”. Each line is an exclude.



This file contains the includes list from your backup. It can be wildcard like above or full path. If there is a space in the path, you must put it in quotes, e.g. “G:\backup\Users\your user name”.



This is the batch file that will create the archive. As mentioned above, Google Drive and 7zip must be installed, and you must have logged into your Google Drive account from the PC that you are backing up. (You must change yourusername in the script to your actual username through the script.)

What this does:

  1. It stops Google Drive so that while creating the archive, there is no synchronization.
  2. It deletes the old backup archive if it exists.
  3. It creates the archive, to your specification from above, and with the password you specify in the script (below). It encrypts the file with AES-256 and encrypts file names.
  4. It restarts Google Drive, which then will sync the newly created archive file with the cloud.
REM KILL GoogleDrive so it doesn't copy when creating archive
Taskkill /IM googledrivesync.exe /F

REM del existing and create new archive
IF EXIST C:\Users\yourusername\Google Drive\backup.7z (
del "C:\Users\yourusername\Google Drive\backup.7z"
"C:\Program Files\7-Zip\7z.exe" a -t7z -mhe=on -mx=9 -pYOUR_STRONG_PASSWORD "C:\Users\yourusername\Google Drive\backup.7z"  -i@C:\Users\yourusername\Documents\backupinclude.txt -xr@C:\Users\yourusername\Documents\backupexclude.txt

REM start GoogleDrive if and when the file is created
IF EXIST "C:\Users\yourusername\Google Drive\backup.7z" (
start "" "C:\Program Files (x86)\Google\Drive\googledrivesync.exe"

The file names and locations must be the same as above except “yourusername” should be your actual username. Otherwise, you need to update it  to reflect the file locations.

The final step is to add a task to the Task Scheduler library to run backuptoGoogleDrive.cmd on a schedule that you define. Here is a very good howto on that. All you have to do is point your task trigger to the backuptoGoogleDrive.cmd file and you are set!

This is meant as a guide to use Google Drive as a backup. Why do I use 7 zip instead of the Windows Backup or some other tool? For me, it is simpler than Windows Backup command line (wbadmin) or other tools and I can restore my files anywhere, not just on Windows . You can use wbadmin or any other archive/backup tool, use whatever is easiest for you.


Update: If you want to only update your archive with the changed files (i.e. incremental backup) then change your compress option to below. This will speed up the backup process immensely and use less CPU power.

IF EXIST "C:\Users\yourusername\Google Drive\backup.7z" (
"C:\Program Files\7-Zip\7z.exe" u -t7z -mhe=on -mx=5 -slp -pYourPassword "C:\Users\yourusername\Google Drive\backup.7z"  -i@C:\Users\yourusername\Documents\backupinclude.txt -xr@C:\Users\yourusername\Documents\backupexclude.txt
REM del "C:\Users\yourusername\Google Drive\backup.*"
) ELSE (
"C:\Program Files\7-Zip\7z.exe" a -t7z -mhe=on -mx=5 -slp -pYourPassword! "C:\Users\yourusername\Google Drive\backup.7z"  -i@C:\Users\yourusername\Documents\backupinclude.txt -xr@C:\Users\yourusername\Documents\backupexclude.txt