{"id":23491189,"url":"https://github.com/devcom-iitb/mongogbackup","last_synced_at":"2025-04-15T06:38:46.327Z","repository":{"id":248379415,"uuid":"824152393","full_name":"DevCom-IITB/mongogbackup","owner":"DevCom-IITB","description":"Remote Mongo DB backup on Google Drive","archived":false,"fork":false,"pushed_at":"2024-10-20T16:38:50.000Z","size":19203,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-28T17:11:13.562Z","etag":null,"topics":["backup","gdrive","mongodb"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/mongogbackup/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DevCom-IITB.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-04T13:18:36.000Z","updated_at":"2024-11-06T16:16:26.000Z","dependencies_parsed_at":"2024-10-20T21:06:41.515Z","dependency_job_id":null,"html_url":"https://github.com/DevCom-IITB/mongogbackup","commit_stats":null,"previous_names":["devcom-iitb/mongogbackup"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevCom-IITB%2Fmongogbackup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevCom-IITB%2Fmongogbackup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevCom-IITB%2Fmongogbackup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevCom-IITB%2Fmongogbackup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DevCom-IITB","download_url":"https://codeload.github.com/DevCom-IITB/mongogbackup/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249023619,"owners_count":21199957,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backup","gdrive","mongodb"],"created_at":"2024-12-25T01:15:59.780Z","updated_at":"2025-04-15T06:38:46.281Z","avatar_url":"https://github.com/DevCom-IITB.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 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 ❤️ by DevCom, 2024","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevcom-iitb%2Fmongogbackup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevcom-iitb%2Fmongogbackup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevcom-iitb%2Fmongogbackup/lists"}