mongogbackup


Namemongogbackup JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummarySecurely Backup MongoDB to Google Drive
upload_time2024-10-20 17:37:47
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License Copyright (c) 2024 DevCom Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords backup drive gdrive google mongo mongodb mongogb mongogbackup remote
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # mongogbackup
Secure Mongo DB backups on Google Drive

## Installation
```bash
$ pip install mongogbackup
```

## Usage
### Import
```python
from  mongogbackup import MongoConfig, MongoGBackup
```

### Initialization
```python
mongo_config = MongoConfig(
                                db_name='your_db',
                                host='localhost',
                                port=27017,
                                # optional parameters below
                                username='root',
                                password='password',
                                auth_db='admin'
                            )
backup_handler =MongoGBackup(
                            mongoConfig=mongo_config,
                            credentials_file='path/credentials.json',  
                            key='fernet_key'
                        )
gdrive = GoogleDriveHandler(
                             credentials_file='path/credentials.json',
                             parent_id = target_folder_id,
                             file_name = name_of_the_file_you_want_to_upload,
                             num_files = how_many_files_you_want_to_keep_in_the_rotating_file_handler               
)
```
## Creating dump
```python
backup_handler.backups.backup(dir='backup_path/dump/')
```
### Compressing the dump
```python
backup_handler.targz.pack(source_path='backup_path/dump/', output_path='filename.tar.gz')
```
### Encrypting the dump
```python
backup_handler.encrypt.encrypt_file('filename.tar.gz', 'destination.file')
```
### Uploading to Google Drive
Add your credentials.json file to your project (you can generate this on Google Cloud Console)
## Simple upload to google drive
```python
gdrive.upload_file_to_drive(file_name, parent_id)
```
## Delete all previous files with same name and upload to Google Drive
```python
gdrive.overwrite_and_upload_to_drive(file_name, parent_id)
```
## Upload to Google Drive with a rotating file handler
```python
gdrive.upload_to_drive_with_rfh(file_name, parent_id, num_files)
```

## Restore Backups
Download the backup file from google drive (say: backup.encr)

### Decrypt the file
```python
backup_handler.encrypt.decrypt_file('backup.encr', 'filename.tar.gz')
```
### Decompressing the tar-gz dump
```python
backup_handler.targz.unpack(source_path='filename.tar.gz', output_path='backup_dir/dump/')
```

### Restoring the dump
```python
backup_handler.backups.restore(bck_dir='backup_dir/dump/')
```

## Hash Checks
To ensure that your backup file has not been tampered with, you can perform a SHA-256 hash check.

```python
backup_handler.hash.generate_file_hash('source.file')
```

You can also save the hash into a txt file by executing
```python
backup_handler.hash.save('hash.txt')
```

or print the hash by executing
```python
print(backup_handler.hash.last_hash())
```

You can also compare the current generated hash with any other string using
```python
backup_handler.hash.compare_generated('hash-string')
# returns True or False on comparision
```

Made with ❤️ by DevCom, 2024
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "mongogbackup",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "\"DevCom, IIT Bombay\" <devcom@iitb.ac.in>",
    "keywords": "backup, drive, gdrive, google, mongo, mongodb, mongogb, mongogbackup, remote",
    "author": null,
    "author_email": "\"DevCom, IIT Bombay\" <devcom@iitb.ac.in>",
    "download_url": "https://files.pythonhosted.org/packages/d3/00/83c9d54e125b1b74a0075aa2417db6c69530986a838cc4929d977dcd86a5/mongogbackup-0.1.1.tar.gz",
    "platform": null,
    "description": "# mongogbackup\nSecure Mongo DB backups on Google Drive\n\n## Installation\n```bash\n$ pip install mongogbackup\n```\n\n## Usage\n### Import\n```python\nfrom  mongogbackup import MongoConfig, MongoGBackup\n```\n\n### Initialization\n```python\nmongo_config = MongoConfig(\n                                db_name='your_db',\n                                host='localhost',\n                                port=27017,\n                                # optional parameters below\n                                username='root',\n                                password='password',\n                                auth_db='admin'\n                            )\nbackup_handler =MongoGBackup(\n                            mongoConfig=mongo_config,\n                            credentials_file='path/credentials.json',  \n                            key='fernet_key'\n                        )\ngdrive = GoogleDriveHandler(\n                             credentials_file='path/credentials.json',\n                             parent_id = target_folder_id,\n                             file_name = name_of_the_file_you_want_to_upload,\n                             num_files = how_many_files_you_want_to_keep_in_the_rotating_file_handler               \n)\n```\n## Creating dump\n```python\nbackup_handler.backups.backup(dir='backup_path/dump/')\n```\n### Compressing the dump\n```python\nbackup_handler.targz.pack(source_path='backup_path/dump/', output_path='filename.tar.gz')\n```\n### Encrypting the dump\n```python\nbackup_handler.encrypt.encrypt_file('filename.tar.gz', 'destination.file')\n```\n### Uploading to Google Drive\nAdd your credentials.json file to your project (you can generate this on Google Cloud Console)\n## Simple upload to google drive\n```python\ngdrive.upload_file_to_drive(file_name, parent_id)\n```\n## Delete all previous files with same name and upload to Google Drive\n```python\ngdrive.overwrite_and_upload_to_drive(file_name, parent_id)\n```\n## Upload to Google Drive with a rotating file handler\n```python\ngdrive.upload_to_drive_with_rfh(file_name, parent_id, num_files)\n```\n\n## Restore Backups\nDownload the backup file from google drive (say: backup.encr)\n\n### Decrypt the file\n```python\nbackup_handler.encrypt.decrypt_file('backup.encr', 'filename.tar.gz')\n```\n### Decompressing the tar-gz dump\n```python\nbackup_handler.targz.unpack(source_path='filename.tar.gz', output_path='backup_dir/dump/')\n```\n\n### Restoring the dump\n```python\nbackup_handler.backups.restore(bck_dir='backup_dir/dump/')\n```\n\n## Hash Checks\nTo ensure that your backup file has not been tampered with, you can perform a SHA-256 hash check.\n\n```python\nbackup_handler.hash.generate_file_hash('source.file')\n```\n\nYou can also save the hash into a txt file by executing\n```python\nbackup_handler.hash.save('hash.txt')\n```\n\nor print the hash by executing\n```python\nprint(backup_handler.hash.last_hash())\n```\n\nYou can also compare the current generated hash with any other string using\n```python\nbackup_handler.hash.compare_generated('hash-string')\n# returns True or False on comparision\n```\n\nMade with \u2764\ufe0f by DevCom, 2024",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 DevCom  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Securely Backup MongoDB to Google Drive",
    "version": "0.1.1",
    "project_urls": {
        "Issues": "https://github.com/DevCom-IITB/mongogbackup/issues",
        "Repository": "https://github.com/DevCom-IITB/mongogbackup"
    },
    "split_keywords": [
        "backup",
        " drive",
        " gdrive",
        " google",
        " mongo",
        " mongodb",
        " mongogb",
        " mongogbackup",
        " remote"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "deda8b13a9f559e7a13631a2d62f2ff43509167e81c81a48163f46623794dbda",
                "md5": "92610684890c1bd6061e91bef7b43062",
                "sha256": "f11f91cc7a9e6a6d1f88392a4f3837720769da3c71577acd06373d41d244ab28"
            },
            "downloads": -1,
            "filename": "mongogbackup-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "92610684890c1bd6061e91bef7b43062",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 10407,
            "upload_time": "2024-10-20T17:37:45",
            "upload_time_iso_8601": "2024-10-20T17:37:45.626517Z",
            "url": "https://files.pythonhosted.org/packages/de/da/8b13a9f559e7a13631a2d62f2ff43509167e81c81a48163f46623794dbda/mongogbackup-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d30083c9d54e125b1b74a0075aa2417db6c69530986a838cc4929d977dcd86a5",
                "md5": "cbba9c24a8f71642f021181fd2b9751d",
                "sha256": "3a046364de600c421ac3e0440e1eaf09ce709fab76239f0d1ee567fc75d41ddc"
            },
            "downloads": -1,
            "filename": "mongogbackup-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "cbba9c24a8f71642f021181fd2b9751d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 20866,
            "upload_time": "2024-10-20T17:37:47",
            "upload_time_iso_8601": "2024-10-20T17:37:47.692920Z",
            "url": "https://files.pythonhosted.org/packages/d3/00/83c9d54e125b1b74a0075aa2417db6c69530986a838cc4929d977dcd86a5/mongogbackup-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-20 17:37:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "DevCom-IITB",
    "github_project": "mongogbackup",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "mongogbackup"
}
        
Elapsed time: 0.38533s