Skip to main content

Backup all your Sendgrid templates on file system or on a S3 bucket.

Project description

backupSendgridTemplates

Backup the dynamic templates of a Sendgrid account.

Backup files can be stored on your local file system or a S3 bucket.

Requirements

  • python 3.8 or higher

Installation

Create and activate a virtual environment. Then

python -m pip install backup-sendgrid-templates

Setup

Some environment variables are required:

  • SENDGRID_API_KEY - Sendgrid API key with full access (https://app.sendgrid.com/settings/api_keys)
  • SENDGRID_TEMPLATES_BUCKET_NAME - the name of your bucket if you want to use S3 as destination
  • SENDGRID_TEMPLATES_BASE_PATH - the path where to store files on your file system

The Sendgrid api key must have full access (more info here).

Usage

Run at command line

> backup_sg_on_file_system     # to create the backup files on your local file system
> backup_sg_on_s3              # to create the backup files on a S3 bucket

Run inside a script

from backup_sendgrid_templates.service import BackupSendgridTemplatesService
from backup_sendgrid_templates.strategies import FileSystemStrategy, S3Strategy

BackupSendgridTemplatesService(strategy=FileSystemStrategy()).run()
# or BackupSendgridTemplatesService(strategy=S3Strategy()).run()

Two files are created for each template: a .json file containing the template metadata (like name, subject, etc.) and an HTML file with the template content.

Restoring a template

Create a new template on the Sendgrid website. In the design page, open the Build tab and expand the advanced section.

Click on Import Drag & Drop HTML and paste the html content retrieved from the backup.

References

Send an email using a Sendgrid dinamyc transactional template: https://docs.sendgrid.com/ui/sending-email/how-to-send-an-email-with-dynamic-transactional-templates

Sendgrid API: https://docs.sendgrid.com/for-developers/sending-email/api-getting-started

Official Python wrapper by Sendgrid: https://github.com/sendgrid/sendgrid-python

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

backup-sendgrid-templates-0.9.0.tar.gz (5.7 kB view hashes)

Uploaded Source

Built Distribution

backup_sendgrid_templates-0.9.0-py3-none-any.whl (8.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page