Knowledge Base

An In-Depth Look at How CodeGuard Works

Overview

By the end of this article you will understand how CodeGuard protects a website or database at each stage of its lifecycle, and which connection method suits your environment. The article covers four stages in order: connection options, where you link your site using File Transfer Protocol (FTP), Secure File Transfer Protocol (SFTP), or a database connection; initial backup, the first complete copy of your data; monitoring, the daily change detection that triggers a ChangeAlert email; and restore, the recovery of a whole site, an individual file, or a database.

Two supporting terms appear throughout:

  • Differential backup – only changed files are transferred after the first backup.
  • Pre-restore backup – a fresh copy taken immediately before a restore so the current state of the site is preserved.

What is CodeGuard

CodeGuard is a website and database backup service. It connects to your hosting environment, takes a complete first copy of your content, checks daily for changes, and stores each new version so you can return the site or database to any earlier point in time.

Connection Options

The first step in activating CodeGuard is to connect your website or database to CodeGuard servers. Two connection families are available: file transfer using File Transfer Protocol (FTP) or Secure File Transfer Protocol (SFTP), and direct database connections to MySQL or Microsoft SQL Server (MS-SQL). The right choice depends on your server configuration and on whether you need file content, database content, or both.

FTP

ProsCons
Supported by almost all hosting providersThe transfer is not encrypted
Access to all files, including those outside your website content such as logs, mail, and user-created foldersDatabases must be set up manually
Lets you select which folders are backed up

SFTP

ProsCons
Transfers are encryptedNot supported by all hosting providers
Access to all files, including those outside your website content such as logs, mail, and user-created foldersDatabases must be set up manually
Lets you select which folders are backed up

MySQL

ProsCons
Connects directly to the database or through a Secure Shell (SSH) tunnelYou may need to allow CodeGuard IP addresses through your firewall
Backs up all content accessible to the database user

MS-SQL

ProsCons
Backs up all content accessible to the database userOnly direct connections are supported, with no SSH tunnel option
You may need to allow CodeGuard IP addresses through your firewall

Initial Backup

The initial backup is the first complete copy of the website or database content that CodeGuard can access through your File Transfer Protocol (FTP), Secure File Transfer Protocol (SFTP), or database connection. Depending on the number of files and the total size, it can take up to four hours, and you can follow its progress in real time in your dashboard. Every backup after this one is differential: only files that changed are transferred and stored.

CodeGuard performs the initial backup in four stages. Process initiation verifies your credentials. File pick up analyses the file structure and creates a Git repository on an Amazon Elastic Compute Cloud (EC2) instance. File transit downloads the files to that instance. Final delivery compresses the repository and uploads it to Amazon Simple Storage Service (S3), where it is encrypted using 256-bit Advanced Encryption Standard (AES) encryption; the temporary copy on EC2 is then deleted.

Static Content Backup Steps (FTP/SFTP)

  1. Test the connection using the same protocol the backup will use.
  2. Create a Git repository on the local server instance.
  3. Build a list of the files on the site.
  4. Add those files to the download queue.
  5. Download each file into the Git repository.
  6. Commit the downloaded files to the repository.
  7. Create a compressed archive of the repository.
  8. Upload the archive to Amazon Simple Storage Service (S3), which encrypts it on upload.
  9. Build the file mix, the record of which file types the site contains.
  10. Record the backup statistics.

Dynamic Content Backup Steps (MySQL/MS-SQL)

Database backups are stored as flat text files containing executable Structured Query Language (SQL) statements. Running those statements recreates the database exactly, so no data transformation is needed at restore time. CodeGuard exports the database with the mysqldump tool for MySQL, or with a Sectigo-developed tool for Microsoft SQL Server (MS-SQL). The process is sequential and stops if any step fails.

  1. Connect to the database directly, through a Secure Shell (SSH) tunnel, or through a direct MS-SQL connection.
  2. Create a Git repository on the local server instance.
  3. Export the database into that repository.
  4. Commit the export file to the repository.
  5. Create a compressed archive of the repository.
  6. Upload the archive to Amazon Simple Storage Service (S3), which encrypts it on upload.
  7. Record the backup statistics, including the number of rows added and deleted.

Monitoring

After the initial backup, CodeGuard checks your site daily for changes and sends a ChangeAlert email when it finds any. Additions, modifications, and deletions between versions are also listed in your dashboard. Monitoring uses a front-end comparison engine that identifies changed files, and back-end version control that stores each new version. Only changed files are transferred, which reduces load on your server.

Static Content Monitoring (FTP/SFTP)

CodeGuard lists every file and folder on your site over File Transfer Protocol (FTP) or Secure File Transfer Protocol (SFTP), skipping folders you excluded during the initial backup. It then compares that list against the previous backup and marks changed files for download. Duration varies with the number and size of your files. A file counts as changed based on:

  • File size
  • Last modification time
  • User or group ownership
  • File permissions

Dynamic Content Monitoring (MySQL/MS-SQL)

There is no separate monitoring step for MySQL or Microsoft SQL Server (MS-SQL), because there is no generic way to detect database changes remotely. CodeGuard downloads the full database each time and compares it with the previous backup. Detected changes appear in your dashboard, but database changes are not included in ChangeAlert emails and are not notified by email at this time.

Repeat Backups

When monitoring detects a change, CodeGuard transfers the changed and added files to the repository and records any deletions, producing a new version in your dashboard. Databases are transmitted in full and compared with the previous version; a new version appears only if changes are found.

Repeat Backup Steps (FTP/SFTP)

Repeat backups follow the initial backup process with four differences. If monitoring finds no changes, the process ends after the monitoring step.

  • Download the existing repository archive from Amazon Simple Storage Service (S3) and extract it on the local server instance, instead of creating a new Git repository.
  • Add only the files marked as changed during monitoring to the download queue.
  • Remove earlier versions of the backup from S3 after the new archive is uploaded.
  • Rebuild the file mix data and record the backup statistics.

Repeat Backup Steps (MySQL/MS-SQL)

Repeat database backups follow the initial database process with two differences: the existing repository archive is downloaded from Amazon Simple Storage Service (S3) and extracted on the local server instance instead of a new Git repository being created, and earlier versions of the backup are removed from S3 after the new archive is uploaded.

Restore

A restore returns your site or database to a selected earlier version from your dashboard. Three restore types are available: a whole site restore, an individual file restore, and a database restore.

Whole Site Restore (FTP/SFTP)

This restore begins with a pre-restore backup, a fresh copy of the current site taken before any changes are made, because the site may have changed since the last completed backup. This makes the process the slowest of the three.

  1. Select the version to restore.
  2. CodeGuard performs a pre-restore backup using the repeat backup process.
  3. CodeGuard builds two file lists: one for the version being restored and one for the current site.
  4. The difference between the two lists becomes a queue of file and folder operations.
  5. The backup archive is downloaded if needed, and the target version is checked out.
  6. CodeGuard opens a connection to your site.
  7. The queue is processed in this order: delete files, delete folders, create folders, upload files, set file permissions.
  8. CodeGuard records the restore statistics and sends email notifications.

Individual File Restore (FTP/SFTP)

An individual file restore runs without a pre-restore backup. You search a chosen backup version using type-ahead search and select the files you need.

  1. Select one or more files, which are added directly to the operations queue.
  2. The site repository is downloaded and the version containing those files is checked out.
  3. The connection is tested and opened using File Transfer Protocol (FTP) or Secure File Transfer Protocol (SFTP).
  4. The selected files are uploaded and their permissions are set.
  5. CodeGuard records the restore statistics and sends email notifications.

Database Restore (MySQL/MS-SQL)

A database restore uses the MySQL or Microsoft SQL Server (MS-SQL) client and always begins with a pre-restore backup.

  1. CodeGuard performs a pre-restore backup.
  2. The repository is downloaded from Amazon Simple Storage Service (S3).
  3. The target restore version is checked out.
  4. A connection is opened to the remote database directly, through a Secure Shell (SSH) tunnel, or through MS-SQL.
  5. The backup file is executed: each table is dropped and recreated, then the table data is imported.
  6. CodeGuard records the restore statistics.

Need assistance?

Contact our team for help with your purchase or issuing your certificate.

Live chat

Call us today