Giter VIP home page Giter VIP logo

mongobackup's Introduction

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)

mongobackup's People

Contributors

zags avatar zagorsky avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.