Skip to main content

Mongo Backup

Mongo backup is designed to handle backing up and restoring a mongo database locally and on s3.

It can be installed by pip:

pip install mongobackup

Example usage follows.

# To do a local backup
from mongobackup import backup
backup("mongo_user", "mongo_password", "/var/backups/mongo/")

# To do a local backup of only one specific database, not every database on
# the server (some MongoDB auth/security configurations require this)
from mongobackup import backup
backup("mongo_user", "mongo_password", "/var/backups/mongo/",
       database="my_database_name")

# To do a local backup and a local backup on attached storage
from mongobackup import backup
backup("mongo_user", "mongo_password", "/var/backups/mongo/",
       attached_directory_path='/mnt/backups/')
# To do a local backup, backup on attached storage, and backup on S3
from mongobackup import backup
backup("mongo_user", "mongo_password", "/var/backups/mongo/",
       attached_directory_path='/mnt/backups/',
       s3_bucket="mongo-backup-bucket", s3_access_key_id="ASDF424242ASDF4242",
       s3_secret_key="lksLKDkakka983jk1DKJa3lkadkjq3askllkad")
# To do a local backup, backup on attached storage, and backup on S3,
# deleting all local and attached storage backups older than 30 days
from mongobackup import backup
backup("mongo_user", "mongo_password", "/var/backups/mongo/",
       attached_directory_path='/mnt/backups/',
       s3_bucket="mongo-backup-bucket", s3_access_key_id="ASDF424242ASDF4242",
       s3_secret_key="lksLKDkakka983jk1DKJa3lkadkjq3askllkad",
       purge_local=30, purge_attached=30)
# To download the latest S3 backup
from mongobackup import s3_download
s3_download("latest.tbz", s3_bucket="mongo-backup-bucket",
            s3_access_key_id="ASDF424242ASDF4242",
            s3_secret_key="lksLKDkakka983jk1DKJa3lkadkjq3askllkad")
# To see all s3 backups and download a particular one
from mongobackup import s3_list, s3_download
s3_list(s3_bucket="mongo-backup-bucket",
        s3_access_key_id="ASDF424242ASDF4242",
        s3_secret_key="lksLKDkakka983jk1DKJa3lkadkjq3askllkad")

s3_download("latest.tbz", s3_bucket="mongo-backup-bucket",
            s3_access_key_id="ASDF424242ASDF4242",
            s3_secret_key="lksLKDkakka983jk1DKJa3lkadkjq3askllkad",
            s3_file_key="backup_2015-03-05_21-40.tbz")
# To restore a backup
from mongobackup import restore
restore("mongo_user", "mongo_password", "latest.tbz")
# If you are having difficulties with restoring a backup from an older version
# of Mongo due to changes in their user permissions system, you can include the
# skip_system_and_user_files flag.
restore("mongo_user", "mongo_password", "latest.tbz", skip_system_and_user_files=True)

Metadata

Release files for mongobackup 0.3.0

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

Source distribution (sdist)

Source distribution for mongobackup 0.3.0
File Size Uploaded Provenance Actions
mongobackup-0.3.0.tar.gz 8.6 kB Without provenance Details for mongobackup-0.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 19.8 kB

Release files / mongobackup-0.3.0.tar.gz

Download URL mongobackup-0.3.0.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f6a0efd8ee2eb1177cc4c42ec024fa79a485b47edc367616b235ef19dae13c69
BLAKE2b-256 checksum
How to use checksums
72c27d36201e2f7662930f67e7624b4df30c2ee56bad74b04d93df56b290a412
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release files / mongobackup-0.3.0-py3-none-any.whl

Download URL mongobackup-0.3.0-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1598a74d981f71bac724a41f044926e1a416e0ae26ff7901cedcf1e6d4d76fe1
BLAKE2b-256 checksum
How to use checksums
470325685d8b4316660610b323979fec0b7666db13ffdf65ea18c7d2642535bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Security for mongobackup 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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