mongogbackup


Namemongogbackup JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
SummarySecurely Backup MongoDB to Google Drive
upload_time2024-07-14 13:50:12
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.encrypt_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/8e/7e/27760ba8d357633666f19a0660ea250dd9c49ad06c635a025efb34883cc5/mongogbackup-0.1.0.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.encrypt_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.0",
    "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": "4806e5d99e1aa7399bbe145e1a280571df5f70079fca227a002dcbd8358735cd",
                "md5": "e1ec4dd030f203d1ad3193c2e18342d6",
                "sha256": "4275099bce1a66e4a71a74a5cececa3e6454f3f670e9544949e2ead42025ebf3"
            },
            "downloads": -1,
            "filename": "mongogbackup-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e1ec4dd030f203d1ad3193c2e18342d6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 10388,
            "upload_time": "2024-07-14T13:50:11",
            "upload_time_iso_8601": "2024-07-14T13:50:11.198952Z",
            "url": "https://files.pythonhosted.org/packages/48/06/e5d99e1aa7399bbe145e1a280571df5f70079fca227a002dcbd8358735cd/mongogbackup-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8e7e27760ba8d357633666f19a0660ea250dd9c49ad06c635a025efb34883cc5",
                "md5": "d6929ac804f7d9688c171d5c346ac387",
                "sha256": "a9f6987939456d3a7aa36fde9955389acc5946424b62860b4b79583a75bca2b1"
            },
            "downloads": -1,
            "filename": "mongogbackup-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "d6929ac804f7d9688c171d5c346ac387",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 10010,
            "upload_time": "2024-07-14T13:50:12",
            "upload_time_iso_8601": "2024-07-14T13:50:12.997085Z",
            "url": "https://files.pythonhosted.org/packages/8e/7e/27760ba8d357633666f19a0660ea250dd9c49ad06c635a025efb34883cc5/mongogbackup-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-14 13:50:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "DevCom-IITB",
    "github_project": "mongogbackup",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "mongogbackup"
}
        
Elapsed time: 0.45223s