Skip to main content

NestBackup

Backup a server to S3 using a short and simple config file.

The config file describes a list of steps to be ran. It can backup databases (PostgreSQL and MySQL), folders (e.g. application media), and send an email with the result of the backup.

All the backup commands are ran as shell calls (e.g. aws s3 ..., pg_dump ...), and each of these calls are logged, so what NestBackup does under the hood is transparent and the steps can be easily reproduced in a shell.

Configuration

NestBackup expects the config file to be in ~/backup.ini. It can be overriden using the NESTBACKUP_CONFIG environment variable.

Sections

Each section describes a job to be ran, and the backup is uploaded to hostname/section_name/[remote_path].

Available jobs:

  • sync: Sinchronizes a path with the remote one. Uses s3 sync.
  • database: Dumps the data of given database, compresses it and uploads it to the bucket. It supports mysql and postgresql.
  • smtp: Sends an email with a report of the jobs that were ran.

The job field is a mandatory attribute for all the section, as is the one that determines which job will be run.

Example config file

[DEFAULT]
# The DEFAULT section contains the default values set to all the jobs
aws_access_key_id=app
aws_secret_access_key=12345678
bucket=backup

[media]
job=sync
local_path=/var/www

[db]
job=database
db_uri=postgresql://app:app@postgres/app
# db_uri=mysql://app:app@mysql/app
# keep 7 files, delete older ones
retention=7

[notify]
job=smtp
server=smtp.mailgun.org
ssl=yes
port=465
username=postmaster@mg.example.com
password=secret123
sender=Example Systems <postmaster@mg.example.com>
recipients=admin@example.com

Usage

Initialize a base config file in ~/backup.ini (overridable by NESTBACKUP_CONFIG environment variable):

nestbackup init

Backup:

nestbackup backup

Restore:

nestbackup restore

Cron example

  0 1     *  *  * bash -lc "nestbackup backup"

Installation

pip3 install nestbackup

Or you can checkout the repository and install it using setup.py:

git checkout git@github.com:jorgebg/nestbackup.git
cd nestbackup
python3 ./setup.py install

Or download it right to your /usr/bin/ folder:

wget https://raw.githubusercontent.com/jorgebg/nestbackup/main/nestbackup.py -o /usr/bin/nestbackup
chmod +x /usr/bin/nestbackup

Requirements

  • Python 3.6+, but I'm successfully using it on machines with Python 3.4
  • AWS CLI
    • pip install awscli

Release files for nestbackup 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nestbackup 0.0.4
File Size Uploaded
nestbackup-0.0.4.tar.gz 8.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nestbackup 0.0.4
File Interpreter ABI Platform
nestbackup-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 16.6 kB

Release files / nestbackup-0.0.4.tar.gz

Download URL nestbackup-0.0.4.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
25c6fa9ccdfe867a63383d88fd74ac7265bdca8510c6322710c7c5ee2986dfb2
BLAKE2b-256 checksum
How to use checksums
6fe7d0fd599098f6451a90c93411eb8d323806bf1e420006bf733f170caa24ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.5

Release files / nestbackup-0.0.4-py3-none-any.whl

Download URL nestbackup-0.0.4-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3da45a5bfa1fbe7fcd457019b68bfcd730a09d17e367972279429ace35d8de79
BLAKE2b-256 checksum
How to use checksums
2ae2f8e168084fbed6088e0c79328b46db81b4b02adbf48db6d214e8c74ba99c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.5

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page