Skip to main content
# PyMongoBack

**PyMongo** Back is a simple Python library designed to help you create MongoDB Backups from both local and remote servers.


## Install

You can easily install it using the following command:

sudo pip3 install pymongoback

> In the server that is going to execute the script, it will be necessary to have installed **MongoDB** or **Mongodb Tools**. Since you need to have installed mongodump.

## Usage

Starting to use PyMongoBack is very simple. You only need to import the library and create an object PyMongoBackup() with the parameters that you prefer.

|Param|Type|Description|
|--|--|--|
|username|str|Username for login MongoDB. Default None.|
|password|str|Password for login MongoDB. Default None.|
|host|str|IP address of the MongoDB server. Default 'localhost'.|
|days_backup|int|Maximum days that are saved backup. Default None (always save).|
|path_backup|str|Path where the backup is saved. Default './BackupMongo'.|
|log|bool|Indicates if the output is written to a log file. Default False.|
|path_log|str|Path where the log is saved. Default './BackupMongo/log'.|
|prefix|str|Indicates the prefix with which the backup will be saved. Default 'back_'.|
|datetime_format|str|Indicates the date format to name the backup. Default '%Y-%m-%d_%H-%M'.|

> Example of name backup file: back_2019-03-09_12-21.zip

|Methods|Description|Arguments|
|--|--|--|
|create_full_backup()|Create a backup of all databases||
|create_backup('db1')|Create a backup of a database|Name of database|
|create_multidb_backup(['db1','db2'])|Create a backup of several databases|List with the databases to make the backup|


### Examples

Backup of all databases on the local server.

import pymongoback

back = pymongoback.PyMongoBackup()
back.create_full_backup()

Backup of a database on the remote server and changing the prefix.

import pymongoback

backone = pymongoback.PyMongoBackup(username='Rafa', password='pass1234',host='192.168.1.221', days_backup=5, prefix='backremote_')
backone.create_backup('db1')

Backup of two databases by changing the path where they are saved and log file activated.

import pymongoback

backmulti = pymongoback.PyMongoBackup(username='Rafa', password='pass1234', path_backup="/var/BackupMongo", log=True, path_log='/var/log/BackupMongo/log', prefix='multiback_')

databases = ['db1','db2']
backmulti.create_multidb_backup(databases)

Download files

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

Source Distribution

pymongoback-1.0.0.tar.gz (5.8 kB view details)

Uploaded Source

File details

Details for the file pymongoback-1.0.0.tar.gz.

File metadata

  • Download URL: pymongoback-1.0.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/2.7

File hashes

Hashes for pymongoback-1.0.0.tar.gz
Algorithm Hash digest
SHA256 470f7b8240ba601fe3124604d9c79914769a89a58b132a8dec86fe0cfabfeb9b
MD5 82cd0b2137c58ee890ed7612cf1f5866
BLAKE2b-256 dc95d59ca7a3b3dd736546262ae859c154b0c1f1498a33fc29c60f8a5a1f356e

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page