Automated Backup with Compression and Encryption

This use case shows how to automate a GoodSync backup job that compresses and encrypts your data with 7-Zip before backing it up.

Install 7-Zip and Add It to PATH

  1. Install 7-Zip. It is free and can be downloaded from the 7-Zip download page.
  2. Add the 7-Zip folder to your Path environment variable. In Windows Search, type environment variable and click Edit environment variables for your account.

Windows Search result for Edit environment variables for your account

  1. Under User variables, select Path, click Edit, and add the folder where 7-Zip is installed, for example C:\Program Files\7-Zip.

Environment Variables window with the Path user variable selected

  1. In the Edit environment variable window, click New, enter the 7-Zip folder path, and click OK in each window.

Edit environment variable window with the 7-Zip folder path added

  1. Open a new Command Prompt and type 7z. If the Path was set correctly, 7-Zip shows its usage information.

Command Prompt showing 7-Zip usage output after running 7z

Create the Compression Script

The job runs a batch script that uses 7-Zip to compress your source folder and encrypt it with a password.

  1. Create a file named backup-script.bat and add these lines:

@echo off
cd /d "<path_to_folder>"
7z a -r Backup -xr!_gsdata_ -p<password> -mhe=on

  1. Replace <path_to_folder> with the full path of the folder to compress. This should be the left (source) folder of your GoodSync job.
  2. Replace <password> with the password to use for encryption.

The script should look similar to this:

Example backup-script.bat file with the 7-Zip compression command

The script does the following:

  • a -r Backup compresses all files and subfolders into an archive named Backup.7z.
  • -xr!_gsdata_ excludes the hidden _gsdata_ folder that GoodSync uses.
  • -p encrypts the archive with your password.
  • -mhe=on also encrypts the file names inside the archive.

IMPORTANT: The password is stored as plain text in the .bat file. Keep the script in a secure location that only you can access, and keep a copy of the password. You cannot open the archive without it.

Create the GoodSync Backup Job

  1. Create a job to back up Backup.7z. If this is your first job, GoodSync prompts you to create one when it opens. Otherwise, click New Job in the upper-left corner. Enter a job name and select Backup as the job type.

New GoodSync Job window with Backup selected as the job type

  1. Set the Left folder to the folder you want to compress and back up.

GoodSync job with the source folder selected on the left side

  1. Set the Right folder to any remote location. For details, see Setting up GoodSync Connect.

GoodSync job with a remote destination selected on the right side

  1. Click the Job Options button in the upper-right corner.

GoodSync Job Options button

  1. On the Filters tab, add /Backup.7z to the Include list. This makes the job back up only the compressed file and nothing else.

Job Options Filters tab with /Backup.7z in the Include list

  1. On the Script/Email tab, set Pre-Analyze to the full path of backup-script.bat.

Job Options Script/Email tab with the batch script set as the Pre-Analyze script

  1. To run the backup automatically, set a schedule on the Auto tab. For details, see Auto.

Job Options Auto tab with scheduling options

Your automated backup is now set up. Before each run, GoodSync runs the script to compress and encrypt your source folder, then backs up Backup.7z to your destination.

Return to top