diff --git a/odoo_database_restore_manager/README.rst b/odoo_database_restore_manager/README.rst new file mode 100644 index 000000000..33678007c --- /dev/null +++ b/odoo_database_restore_manager/README.rst @@ -0,0 +1,52 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: https://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +Odoo Database Restore Manager +============================= +All the database backups that are stored by module auto_database_backup can be +restored and downloaded using this module. + +Configuration +============= +The auto_database_backup module should be installed ( Here is the link: https://apps.odoo.com/apps/modules/15.0/auto_database_backup/ ) +All the requirements for auto_database_backup module should be installed. + +Installation +============ +- www.odoo.com/documentation/15.0/setup/install.html +- Install our custom addon + +License +------- +General Public License, Version 3 (AGPL v3). +(https://www.gnu.org/licenses/agpl-3.0-standalone.html) + +Company +------- +* `Cybrosys Techno Solutions `__ + +Credits +------- +* Developer: (V15) Aslam A K, Contact: odoo@cybrosys.com + +Contacts +-------- +* Mail Contact : odoo@cybrosys.com +* Website : https://cybrosys.com + +Bug Tracker +----------- +Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. + +Maintainer +========== +.. image:: https://cybrosys.com/images/logo.png + :target: https://cybrosys.com + +This module is maintained by Cybrosys Technologies. +For support and more information, please visit https://www.cybrosys.com + +Further information +=================== +HTML Description: ``__ diff --git a/odoo_database_restore_manager/__init__.py b/odoo_database_restore_manager/__init__.py new file mode 100644 index 000000000..3e121b6a1 --- /dev/null +++ b/odoo_database_restore_manager/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Aslam AK (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################### +from . import models +from . import wizard diff --git a/odoo_database_restore_manager/__manifest__.py b/odoo_database_restore_manager/__manifest__.py new file mode 100644 index 000000000..fdfa61881 --- /dev/null +++ b/odoo_database_restore_manager/__manifest__.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Aslam AK (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################### +{ + 'name': "Odoo Database Restore Manager Odoo15", + 'version': "15.0.1.0.0'", + 'category': "Extra Tools", + 'summary': """Easily Restore The Previous Database Backups Stored in Different Locations like Google Drive, + Dropbox, Onedrive, Nextcloud and Amazon S3""", + 'description': """Easily Restore The Previous Database Backups Stored in Different Locations like Google Drive, + Dropbox, Onedrive, Nextcloud and Amazon S3, Odoo15, backup, restore""", + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': "https://www.cybrosys.com", + 'depends': ['base_setup', 'auto_database_backup'], + 'data': [ + 'security/ir.model.access.csv', + 'views/database_manager_views.xml', + 'views/res_config_settings_views.xml', + 'wizard/database_restore_views.xml' + ], + 'assets': { + 'web.assets_backend': [ + '/odoo_database_restore_manager/static/src/js/db_restore.js', + '/odoo_database_restore_manager/static/src/scss/db_restore.scss' + ], + 'web.assets_qweb': [ + '/odoo_database_restore_manager/static/src/xml/db_restore_dashboard.xml', + ], + }, + 'external_dependencies': {'python': ['dropbox']}, + 'images': ['static/description/banner.jpg'], + 'license': 'LGPL-3', + 'installable': True, + 'auto_install': False, + 'application': True, +} diff --git a/odoo_database_restore_manager/doc/RELEASE_NOTES.md b/odoo_database_restore_manager/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..638da2f14 --- /dev/null +++ b/odoo_database_restore_manager/doc/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 05.01.2023 +#### Version 15.0.1.0.0 +#### ADD +- Initial commit for Odoo Database Restore Manager diff --git a/odoo_database_restore_manager/models/__init__.py b/odoo_database_restore_manager/models/__init__.py new file mode 100644 index 000000000..d745467f2 --- /dev/null +++ b/odoo_database_restore_manager/models/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Aslam AK (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################### +from . import database_manager +from . import res_config_settings diff --git a/odoo_database_restore_manager/models/database_manager.py b/odoo_database_restore_manager/models/database_manager.py new file mode 100644 index 000000000..7d492a009 --- /dev/null +++ b/odoo_database_restore_manager/models/database_manager.py @@ -0,0 +1,235 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Aslam AK (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################### +import boto3 +import dropbox +import ftplib +import nextcloud_client +import os +import paramiko +import requests +from datetime import datetime +from odoo import fields, models + + +class DatabaseRestoreManager(models.Model): + """ + Dashboard model to view all database backups + """ + _name = 'database.manager' + _description = 'Dashboard Model to View All Database Backups' + + def action_import_files(self): + """ + Import latest backups from the storages configured + """ + return_data = {} + backup_count = int(self.env['ir.config_parameter'].get_param( + 'odoo_database_restore_manager.backup_count')) + if backup_count <= 0: + return ['error', 'Please set a backup count', 'Storages'] + if not self.env['db.backup.configure'].search([]): + return ['error', 'No Backups Found', 'auto_database_backup'] + for rec in self.env['db.backup.configure'].search([]): + if rec.backup_destination == 'dropbox': + try: + dbx_dict = {} + dbx = dropbox.Dropbox(app_key=rec.dropbox_client_key, + app_secret=rec.dropbox_client_secret, + oauth2_refresh_token= + rec.dropbox_refresh_token) + response = dbx.files_list_folder(path=rec.dropbox_folder) + for files in response.entries: + file = dbx.files_get_temporary_link( + path=files.path_lower) + dbx_dict[file.metadata.name] = \ + file.link, 'Dropbox', files.client_modified + return_data.update(dict(list( + sorted(dbx_dict.items(), key=lambda x: x[1][2], + reverse=True))[:backup_count])) + except Exception as error: + return ['error', error, 'Dropbox'] + if rec.backup_destination == 'onedrive': + try: + onedrive_dict = {} + if rec.onedrive_token_validity <= fields.Datetime.now(): + rec.generate_onedrive_refresh_token() + url = "https://graph.microsoft.com/v1.0/me/drive/items" \ + "/%s/children?Content-Type=application/json" \ + % rec.onedrive_folder_key + response = requests.request("GET", url, headers={ + 'Authorization': 'Bearer "' + + rec.onedrive_access_token + '"'}, + data={}) + for file in response.json().get('value'): + if list(file.keys())[0] == '@microsoft.graph.downloadUrl': + onedrive_dict[file['name']] = file[ + '@microsoft.graph.downloadUrl'], 'OneDrive', \ + datetime.strptime( + file['createdDateTime'], + "%Y-%m-%dT%H:%M:%S.%fZ").strftime( + "%Y-%m-%d %H:%M:%S") + return_data.update(dict(list( + sorted(onedrive_dict.items(), key=lambda x: x[1][2], + reverse=True))[:backup_count])) + except Exception as error: + return ['error', error, 'OneDrive'] + if rec.backup_destination == 'google_drive': + try: + gdrive_dict = {} + if rec.gdrive_token_validity <= fields.Datetime.now(): + rec.generate_gdrive_refresh_token() + response = requests.get( + f"https://www.googleapis.com/drive/v3/files", + headers={ + "Authorization": "Bearer %s" + % rec.gdrive_access_token}, + params={ + "q": f"'{rec.google_drive_folder_key}' in parents", + "fields": + "files(name, webContentLink, createdTime)", }) + for file_data in response.json().get("files", []): + gdrive_dict[file_data.get("name")] = file_data.get( + "webContentLink"), 'Google Drive', \ + datetime.strptime(file_data.get("createdTime"), + "%Y-%m-%dT%H:%M:%S.%fZ").strftime( + "%Y-%m-%d %H:%M:%S") + return_data.update(dict(list( + sorted(gdrive_dict.items(), key=lambda x: x[1][2], + reverse=True))[:backup_count])) + except Exception as error: + return ['error', error, 'Google Drive'] + if rec.backup_destination == 'local': + try: + local_dict = {} + for root, dirs, files in os.walk(rec.backup_path): + for file in files: + file_path = os.path.join(root, file) + create_date = datetime.fromtimestamp( + os.path.getctime(file_path)).strftime( + "%Y-%m-%d %H:%M:%S") + local_dict[ + file] = file_path, 'Local Storage', create_date + return_data.update(dict(list( + sorted(local_dict.items(), key=lambda x: x[1][2], + reverse=True))[:backup_count])) + except Exception as error: + return ['error', error, 'Local'] + if rec.backup_destination == 'ftp': + try: + ftp_dict = {} + ftp_server = ftplib.FTP() + ftp_server.connect(rec.ftp_host, int(rec.ftp_port)) + ftp_server.login(rec.ftp_user, rec.ftp_password) + for file in ftp_server.nlst(rec.ftp_path): + file_details = ftp_server.voidcmd("MDTM " + file) + ftp_dict[os.path.basename( + file)] = file, 'FTP Storage', datetime.strptime( + file_details[4:].strip(), "%Y%m%d%H%M%S") + ftp_server.quit() + return_data.update(dict(list( + sorted(ftp_dict.items(), key=lambda x: x[1][2], + reverse=True))[:backup_count])) + except Exception as error: + return ['error', error, 'FTP server'] + if rec.backup_destination == 'sftp': + sftp_client = paramiko.SSHClient() + sftp_client.set_missing_host_key_policy( + paramiko.AutoAddPolicy()) + try: + sftp_dict = {} + sftp_client.connect(hostname=rec.sftp_host, + username=rec.sftp_user, + password=rec.sftp_password, + port=rec.sftp_port) + sftp_server = sftp_client.open_sftp() + sftp_server.chdir(rec.sftp_path) + file_list = sftp_server.listdir() + for file_name in file_list: + sftp_dict[file_name] = os.path.join(rec.sftp_path, + file_name),\ + 'SFTP Storage', datetime.fromtimestamp( + sftp_server.stat(file_name).st_mtime) + sftp_server.close() + return_data.update(dict(list( + sorted(sftp_dict.items(), key=lambda x: x[1][2], + reverse=True))[:backup_count])) + except Exception as error: + return ['error', error, 'SFTP server'] + finally: + sftp_client.close() + if rec.backup_destination == 'next_cloud': + try: + nxt_dixt = {} + nc_access = nextcloud_client.Client(rec.domain) + nc_access.login(rec.next_cloud_user_name, + rec.next_cloud_password) + for file_name in [file.name for file in + nc_access.list( + '/' + rec.nextcloud_folder_key)]: + link_info = nc_access.share_file_with_link( + '/' + rec.nextcloud_folder_key + '/' + file_name, + publicUpload=False) + file_info = nc_access.file_info( + '/' + rec.nextcloud_folder_key + '/' + file_name) + input_datetime = datetime.strptime( + file_info.attributes['{DAV:}getlastmodified'], + "%a, %d %b %Y %H:%M:%S %Z") + output_date_str = input_datetime.strftime( + "%Y-%m-%d %H:%M:%S") + nxt_dixt[ + file_name] = link_info.get_link() + '/download', 'Nextcloud', output_date_str + return_data.update(dict(list(sorted(nxt_dixt.items(), + key=lambda x: x[1][2], + reverse=True))[ + :backup_count])) + except Exception as e: + # Handle any exceptions that occur during SFTP Storage + # backup retrieval + return ['error', e, 'Nextcloud'] + if rec.backup_destination == 'amazon_s3': + try: + s3_dixt = {} + client = boto3.client('s3', aws_access_key_id=rec.aws_access_key, + aws_secret_access_key=rec.aws_secret_access_key) + region = client.get_bucket_location(Bucket=rec.bucket_file_name) + client = boto3.client( + 's3', region_name=region['LocationConstraint'], + aws_access_key_id=rec.aws_access_key, + aws_secret_access_key=rec.aws_secret_access_key + ) + response = client.list_objects(Bucket=rec.bucket_file_name, Prefix=rec.aws_folder_name) + for data in response['Contents']: + if data['Size'] != 0: + url = client.generate_presigned_url( + ClientMethod='get_object', + Params={'Bucket': rec.bucket_file_name, + 'Key': data['Key']}, ExpiresIn=3600) + s3_dixt[data['Key']] = url, 'AmazonS3', data['LastModified'] + return_data.update(dict(list(sorted(s3_dixt.items(), + key=lambda x: x[1][2], + reverse=True))[ + :backup_count])) + except Exception as e: + # Handle any exceptions that occur during amazon_s3 Storage + # backup retrieval + return ['error', e, 'Amazon S3'] + return return_data diff --git a/odoo_database_restore_manager/models/res_config_settings.py b/odoo_database_restore_manager/models/res_config_settings.py new file mode 100644 index 000000000..4f7dd625d --- /dev/null +++ b/odoo_database_restore_manager/models/res_config_settings.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Aslam AK (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################### +from odoo import fields, models + + +class ResConfigSettings(models.TransientModel): + """ + Configure the number of backups for restore + """ + _inherit = 'res.config.settings' + + backup_count = fields.Integer(string='Backup Count', + help='Number of backups to list for restore', + config_parameter= + 'odoo_database_restore_manager.backup_count') diff --git a/odoo_database_restore_manager/security/ir.model.access.csv b/odoo_database_restore_manager/security/ir.model.access.csv new file mode 100644 index 000000000..3b169fed3 --- /dev/null +++ b/odoo_database_restore_manager/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink +access_database_manager,access.database.manager,model_database_manager,base.group_user,1,1,1,1 +access_database_restore,access.database.restore,model_database_restore,base.group_user,1,1,1,1 diff --git a/odoo_database_restore_manager/static/description/assets/icons/check.png b/odoo_database_restore_manager/static/description/assets/icons/check.png new file mode 100644 index 000000000..c8e85f51d Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/check.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/chevron.png b/odoo_database_restore_manager/static/description/assets/icons/chevron.png new file mode 100644 index 000000000..2089293d6 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/chevron.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/cogs.png b/odoo_database_restore_manager/static/description/assets/icons/cogs.png new file mode 100644 index 000000000..95d0bad62 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/cogs.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/consultation.png b/odoo_database_restore_manager/static/description/assets/icons/consultation.png new file mode 100644 index 000000000..8319d4baa Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/consultation.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/ecom-black.png b/odoo_database_restore_manager/static/description/assets/icons/ecom-black.png new file mode 100644 index 000000000..a9385ff13 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/ecom-black.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/education-black.png b/odoo_database_restore_manager/static/description/assets/icons/education-black.png new file mode 100644 index 000000000..3eb09b27b Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/education-black.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/hotel-black.png b/odoo_database_restore_manager/static/description/assets/icons/hotel-black.png new file mode 100644 index 000000000..130f613be Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/hotel-black.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/license.png b/odoo_database_restore_manager/static/description/assets/icons/license.png new file mode 100644 index 000000000..a5869797e Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/license.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/lifebuoy.png b/odoo_database_restore_manager/static/description/assets/icons/lifebuoy.png new file mode 100644 index 000000000..658d56ccc Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/lifebuoy.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/manufacturing-black.png b/odoo_database_restore_manager/static/description/assets/icons/manufacturing-black.png new file mode 100644 index 000000000..697eb0e9f Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/manufacturing-black.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/pos-black.png b/odoo_database_restore_manager/static/description/assets/icons/pos-black.png new file mode 100644 index 000000000..97c0f90c1 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/pos-black.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/puzzle.png b/odoo_database_restore_manager/static/description/assets/icons/puzzle.png new file mode 100644 index 000000000..65cf854e7 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/puzzle.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/restaurant-black.png b/odoo_database_restore_manager/static/description/assets/icons/restaurant-black.png new file mode 100644 index 000000000..4a35eb939 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/restaurant-black.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/service-black.png b/odoo_database_restore_manager/static/description/assets/icons/service-black.png new file mode 100644 index 000000000..301ab51cb Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/service-black.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/trading-black.png b/odoo_database_restore_manager/static/description/assets/icons/trading-black.png new file mode 100644 index 000000000..9398ba2f1 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/trading-black.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/training.png b/odoo_database_restore_manager/static/description/assets/icons/training.png new file mode 100644 index 000000000..884ca024d Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/training.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/update.png b/odoo_database_restore_manager/static/description/assets/icons/update.png new file mode 100644 index 000000000..ecbc5a01a Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/update.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/user.png b/odoo_database_restore_manager/static/description/assets/icons/user.png new file mode 100644 index 000000000..6ffb23d9f Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/user.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/wrench.png b/odoo_database_restore_manager/static/description/assets/icons/wrench.png new file mode 100644 index 000000000..6c04dea0f Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/wrench.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/categories.png b/odoo_database_restore_manager/static/description/assets/misc/categories.png new file mode 100644 index 000000000..bedf1e0b1 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/categories.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/check-box.png b/odoo_database_restore_manager/static/description/assets/misc/check-box.png new file mode 100644 index 000000000..42caf24b9 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/check-box.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/compass.png b/odoo_database_restore_manager/static/description/assets/misc/compass.png new file mode 100644 index 000000000..d5fed8faa Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/compass.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/corporate.png b/odoo_database_restore_manager/static/description/assets/misc/corporate.png new file mode 100644 index 000000000..2eb13edbf Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/corporate.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/customer-support.png b/odoo_database_restore_manager/static/description/assets/misc/customer-support.png new file mode 100644 index 000000000..79efc72ed Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/customer-support.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/cybrosys-logo.png b/odoo_database_restore_manager/static/description/assets/misc/cybrosys-logo.png new file mode 100644 index 000000000..cc3cc0ccf Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/cybrosys-logo.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/features.png b/odoo_database_restore_manager/static/description/assets/misc/features.png new file mode 100644 index 000000000..b41769f77 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/features.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/logo.png b/odoo_database_restore_manager/static/description/assets/misc/logo.png new file mode 100644 index 000000000..478462d3e Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/logo.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/pictures.png b/odoo_database_restore_manager/static/description/assets/misc/pictures.png new file mode 100644 index 000000000..56d255fe9 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/pictures.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/pie-chart.png b/odoo_database_restore_manager/static/description/assets/misc/pie-chart.png new file mode 100644 index 000000000..426e05244 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/pie-chart.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/right-arrow.png b/odoo_database_restore_manager/static/description/assets/misc/right-arrow.png new file mode 100644 index 000000000..730984a06 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/right-arrow.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/star.png b/odoo_database_restore_manager/static/description/assets/misc/star.png new file mode 100644 index 000000000..2eb9ab29f Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/star.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/support.png b/odoo_database_restore_manager/static/description/assets/misc/support.png new file mode 100644 index 000000000..4f18b8b82 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/support.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/whatsapp.png b/odoo_database_restore_manager/static/description/assets/misc/whatsapp.png new file mode 100644 index 000000000..d513a5356 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/whatsapp.png differ diff --git a/odoo_database_restore_manager/static/description/assets/modules/1.gif b/odoo_database_restore_manager/static/description/assets/modules/1.gif new file mode 100644 index 000000000..591c8b18d Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/modules/1.gif differ diff --git a/odoo_database_restore_manager/static/description/assets/modules/2.png b/odoo_database_restore_manager/static/description/assets/modules/2.png new file mode 100644 index 000000000..3599974eb Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/modules/2.png differ diff --git a/odoo_database_restore_manager/static/description/assets/modules/3.png b/odoo_database_restore_manager/static/description/assets/modules/3.png new file mode 100644 index 000000000..53de17dbf Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/modules/3.png differ diff --git a/odoo_database_restore_manager/static/description/assets/modules/4.png b/odoo_database_restore_manager/static/description/assets/modules/4.png new file mode 100644 index 000000000..492980ad0 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/modules/4.png differ diff --git a/odoo_database_restore_manager/static/description/assets/modules/5.png b/odoo_database_restore_manager/static/description/assets/modules/5.png new file mode 100644 index 000000000..903a921af Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/modules/5.png differ diff --git a/odoo_database_restore_manager/static/description/assets/modules/6.png b/odoo_database_restore_manager/static/description/assets/modules/6.png new file mode 100644 index 000000000..6bc155887 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/modules/6.png differ diff --git a/odoo_database_restore_manager/static/description/assets/screenshots/1.png b/odoo_database_restore_manager/static/description/assets/screenshots/1.png new file mode 100644 index 000000000..d683abf49 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/screenshots/1.png differ diff --git a/odoo_database_restore_manager/static/description/assets/screenshots/2.png b/odoo_database_restore_manager/static/description/assets/screenshots/2.png new file mode 100644 index 000000000..d0de3090d Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/screenshots/2.png differ diff --git a/odoo_database_restore_manager/static/description/assets/screenshots/3.png b/odoo_database_restore_manager/static/description/assets/screenshots/3.png new file mode 100644 index 000000000..623988ea1 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/screenshots/3.png differ diff --git a/odoo_database_restore_manager/static/description/assets/screenshots/4.png b/odoo_database_restore_manager/static/description/assets/screenshots/4.png new file mode 100644 index 000000000..e6aca5f0f Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/screenshots/4.png differ diff --git a/odoo_database_restore_manager/static/description/assets/screenshots/5.png b/odoo_database_restore_manager/static/description/assets/screenshots/5.png new file mode 100644 index 000000000..e73372e12 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/screenshots/5.png differ diff --git a/odoo_database_restore_manager/static/description/assets/screenshots/6.png b/odoo_database_restore_manager/static/description/assets/screenshots/6.png new file mode 100644 index 000000000..57a95d31a Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/screenshots/6.png differ diff --git a/odoo_database_restore_manager/static/description/assets/screenshots/7.png b/odoo_database_restore_manager/static/description/assets/screenshots/7.png new file mode 100644 index 000000000..0a2f40ceb Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/screenshots/7.png differ diff --git a/odoo_database_restore_manager/static/description/assets/screenshots/hero.gif b/odoo_database_restore_manager/static/description/assets/screenshots/hero.gif new file mode 100644 index 000000000..168a9cb48 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/screenshots/hero.gif differ diff --git a/odoo_database_restore_manager/static/description/banner.jpg b/odoo_database_restore_manager/static/description/banner.jpg new file mode 100644 index 000000000..56e9fec3e Binary files /dev/null and b/odoo_database_restore_manager/static/description/banner.jpg differ diff --git a/odoo_database_restore_manager/static/description/icon.png b/odoo_database_restore_manager/static/description/icon.png new file mode 100644 index 000000000..da3264286 Binary files /dev/null and b/odoo_database_restore_manager/static/description/icon.png differ diff --git a/odoo_database_restore_manager/static/description/index.html b/odoo_database_restore_manager/static/description/index.html new file mode 100644 index 000000000..3bd8f0179 --- /dev/null +++ b/odoo_database_restore_manager/static/description/index.html @@ -0,0 +1,714 @@ +
+ +
+ +
+
+ Community +
+
+ Enterprise +
+
+
+ +
+
+
+ +

+ Odoo Database Restore Manager

+

+ Easily Restore The Previous Database Backups Stored in Different Locations like Google Drive, + Dropbox, Onedrive, Nextcloud and Amazon S3 +

+ + +
+
+
+
+ + +
+
+ +
+

+ Explore This + Module

+
+ + + + +
+
+ +
+

+ Overview +

+
+
+
+ Odoo Database Restore Manager enhances the database restoration process + by seamlessly restoring database backups that were previously uploaded + to different storage locations using the " + auto_database_backup " module. + With the Odoo Database Restore Manager, users can effortlessly restore + their Odoo databases from previously created backups. It simplifies the + restoration process and provides a centralized interface to manage and + restore backups stored in various locations. + The app integrates seamlessly with the "auto_database_backup" module, + which automatically creates backups of Odoo databases and uploads them + to different storage options such as local directories, FTP servers, + SFTP servers, Google Drive, Dropbox, and OneDrive. By utilizing + the auto_database_backup module, users can schedule regular backups and + store them in diverse storage locations for enhanced data protection. +
+
+ + + +
+
+ +
+

+ Features +

+
+
+
+
+ + Easy and Flexible Restoration +
+ +
+ + Restore Previous Database from Google Drive +
+ +
+ + Restore Previous Database from Dropbox +
+ +
+ + Restore Previous Database from Onedrive +
+
+ + Restore Previous Database from Google Drive +
+
+ + Restore Previous Database from Nextcloud +
+
+ + Restore Previous Database from Amazon S3 +
+
+
+ + + +
+
+ +
+

+ Screenshots +

+
+
+
+ +
+

+ Configure Backups by + Automatic Database Backup Module +

+

+

+ +
+ +
+

+ Configure the Number of Latest Backups to be Shown +

+

+

+ +
+ + +
+

+ Database Restore Manager View +

+

+

+ +
+ +
+

+ Filter on Storage Location and Restore Button +

+

+ +

+ +
+

+ Restoring Database Backup +

+

+ New Database Name and Master Password +

+ +
+ +
+

+ Restore Complete +

+

+

+ +
+ +
+

+ Download Backups +

+

+

+ +
+
+
+ + + +
+
+ +
+

+ Related + Products +

+
+
+
+ +
+
+ + + + +
+
+ +
+

+ Our Services +

+
+ +
+
+
+
+ +
+
+ Odoo + Customization
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Support
+
+ + +
+
+ +
+
+ Hire + Odoo + Developer
+
+ +
+
+ +
+
+ Odoo + Integration
+
+ +
+
+ +
+
+ Odoo + Migration
+
+
+
+ +
+
+ Odoo + Consultancy
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Licensing Consultancy
+
+
+ +
+ + + + +
+
+ +
+

+ Our + Industries +

+
+ +
+
+
+
+ +
+ Trading +
+

+ Easily procure + and + sell your products

+
+
+ +
+
+ +
+ POS +
+

+ Easy + configuration + and convivial experience

+
+
+ +
+
+ +
+ Education +
+

+ A platform for + educational management

+
+
+ +
+
+ +
+ Manufacturing +
+

+ Plan, track and + schedule your operations

+
+
+ +
+
+ +
+ E-commerce & Website +
+

+ Mobile + friendly, + awe-inspiring product pages

+
+
+ +
+
+ +
+ Service Management +
+

+ Keep track of + services and invoice

+
+
+ +
+
+ +
+ Restaurant +
+

+ Run your bar or + restaurant methodically

+
+
+ +
+
+ +
+ Hotel Management +
+

+ An + all-inclusive + hotel management application

+
+
+
+
+ + + + +
+
+ +
+

+ Support +

+
+
+
+
+
+
+ +
+
+

Need Help?

+

Got questions or need help? + Get in touch.

+ +

+ odoo@cybrosys.com

+
+
+
+
+
+
+
+ +
+
+

WhatsApp

+

Say hi to us on WhatsApp!

+ +

+ +91 86068 + 27707

+
+
+
+
+
+
+
+ +
+
+
+ \ No newline at end of file diff --git a/odoo_database_restore_manager/static/src/img/odoo_logo.png b/odoo_database_restore_manager/static/src/img/odoo_logo.png new file mode 100644 index 000000000..dc9ab9a3c Binary files /dev/null and b/odoo_database_restore_manager/static/src/img/odoo_logo.png differ diff --git a/odoo_database_restore_manager/static/src/img/restore.png b/odoo_database_restore_manager/static/src/img/restore.png new file mode 100644 index 000000000..2b15683fc Binary files /dev/null and b/odoo_database_restore_manager/static/src/img/restore.png differ diff --git a/odoo_database_restore_manager/static/src/js/db_restore.js b/odoo_database_restore_manager/static/src/js/db_restore.js new file mode 100644 index 000000000..355754c58 --- /dev/null +++ b/odoo_database_restore_manager/static/src/js/db_restore.js @@ -0,0 +1,77 @@ +odoo.define('odoo_database_restore_manager.dashboard', function (require) { + 'use strict'; + var AbstractAction = require('web.AbstractAction'); + var core = require('web.core'); + var rpc = require('web.rpc'); + var DbRestoreDashboard = AbstractAction.extend({ + template: 'DbRestoreDashboard', + events: { + 'click #db_restore': 'restore', + 'change #db_location': 'filter_location', + }, +// Appends backups retrieved by function(action_import_files) to div db_restore_files. + init: function () { + this._super.apply(this, arguments); + var self = this; + rpc.query({ + model: 'database.manager', + method: 'action_import_files', + args: [''] + }).then(function (result) { + if (result[0] == 'error') { + self.do_action({ + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'message': 'Failed to Load Files from ' + result[2] + ' [ ' + result[1] + ' ]', + 'type': 'warning', + 'sticky': false, + } + }); + } else { + var count = 1; + _.each(result, function (name, index) { + var downloadBackup = ''; + if (['Dropbox', 'OneDrive', 'Google Drive', 'Nextcloud', 'AmazonS3'].includes(name[1])) { + downloadBackup = ' '; + } + self.$el.find('.db_restore_files').append('' + count + '' + index + '' + name[1] + '' + name[2] + '' + downloadBackup + ''); + count++; + }); + } + }); + }, +// Open up the wizard to restore the selected backup file. + restore: function (ev) { + this.do_action({ + name: "Restore Database", + type: 'ir.actions.act_window', + res_model: 'database.restore', + view_mode: 'form', + view_type: 'form', + views: [[false, 'form']], + context: { + default_db_file: ev.target.getAttribute('value'), + default_backup_location: this.$(ev.target).closest('tr').find('td').eq(2).text() + }, + target: 'new', + }); + }, +// Filter backups based on storage types. + filter_location: function (ev) { + var e = this.$("#db_location").get(0); + var self = this; + this.$('.file_row').each(function (index, name) { + self.$(this).hide(); + var location = self.$(name).find('td').eq(2).text(); + if (e.value === 'all_backups') { + self.$(this).show(); + } else if (e.value === location) { + self.$(this).show(); + } + }); + }, + }); + core.action_registry.add("database_manager_dashboard", DbRestoreDashboard); + return DbRestoreDashboard; +}); diff --git a/odoo_database_restore_manager/static/src/scss/db_restore.scss b/odoo_database_restore_manager/static/src/scss/db_restore.scss new file mode 100644 index 000000000..95fe0da0b --- /dev/null +++ b/odoo_database_restore_manager/static/src/scss/db_restore.scss @@ -0,0 +1,60 @@ +#db_location { + outline: none; + border: none; + font-size: 15px; + box-shadow: none; + background-color: #fff; + padding: 4px 24px; + height: 40px; +} +.db_restore_content { + height: 100%; + width: 100%; +} +#db_restore { + color: #ffffff; + width: 90px; + background-color: #b1b1b1; + height: 30px; + border: none; + text-transform: capitalize; +} +#db_restore:hover { + background-color: #000; + color: #fff; +} +.backup_download { + color: #ffffff; + width: 30px; + background-color: #b1b1b1; + height: 30px; + border: none; + text-transform: capitalize; +} +.backup_download:hover { + background-color: #000; + color: #fff; +} +.table-head { + background-color: #2e2e2e; + color: #fff; + border: 1px solid #eaeaea; +} +.file_row { + --table-bg: #ffffff; + color: #000; + border: 1px solid #eaeaea; +} +.scrollable-table { + height: 75vh; + overflow-y: auto; +} +.company_image { + max-width: 200px; + max-height: 100px; + margin: 20px; +} +.option { + background-color: black; + color: white; +} diff --git a/odoo_database_restore_manager/static/src/xml/db_restore_dashboard.xml b/odoo_database_restore_manager/static/src/xml/db_restore_dashboard.xml new file mode 100644 index 000000000..3e941aa51 --- /dev/null +++ b/odoo_database_restore_manager/static/src/xml/db_restore_dashboard.xml @@ -0,0 +1,53 @@ + + + diff --git a/odoo_database_restore_manager/views/database_manager_views.xml b/odoo_database_restore_manager/views/database_manager_views.xml new file mode 100644 index 000000000..5d396b57f --- /dev/null +++ b/odoo_database_restore_manager/views/database_manager_views.xml @@ -0,0 +1,13 @@ + + + + + Database Restore + database_manager_dashboard + current + + + diff --git a/odoo_database_restore_manager/views/res_config_settings_views.xml b/odoo_database_restore_manager/views/res_config_settings_views.xml new file mode 100644 index 000000000..e6198b65e --- /dev/null +++ b/odoo_database_restore_manager/views/res_config_settings_views.xml @@ -0,0 +1,25 @@ + + + + + + res.config.settings.view.form.inherit.odoo_database_restore_manager + + res.config.settings + + + +
+
+
+
+
+ + + + diff --git a/odoo_database_restore_manager/wizard/__init__.py b/odoo_database_restore_manager/wizard/__init__.py new file mode 100644 index 000000000..258957731 --- /dev/null +++ b/odoo_database_restore_manager/wizard/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Aslam AK (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################### +from . import database_restore diff --git a/odoo_database_restore_manager/wizard/database_restore.py b/odoo_database_restore_manager/wizard/database_restore.py new file mode 100644 index 000000000..76bd3cace --- /dev/null +++ b/odoo_database_restore_manager/wizard/database_restore.py @@ -0,0 +1,106 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2023-TODAY Cybrosys Technologies() +# Author: Aslam AK (odoo@cybrosys.com) +# +# You can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# (LGPL v3) along with this program. +# If not, see . +# +############################################################################### +import ftplib +import gdown +import odoo +import odoo.modules.registry +import os +import paramiko +import requests +import tempfile +from odoo import fields, models, _ +from odoo.exceptions import UserError +from odoo.http import dispatch_rpc +from odoo.service import db +from odoo.tools.misc import str2bool + + +class DataBaseRestore(models.TransientModel): + """ + Database Restore Model + """ + _name = "database.restore" + _description = "Restore Backups" + + db_file = fields.Char(string="File", + help="Path or URL to the database backup file") + db_name = fields.Char(string="Database Name", + help="Name of the database to restore") + db_master_pwd = fields.Char(string="Database Master Password", + help="Master password for the database") + backup_location = fields.Char(string="Backup Location", + help="Location where the database backup is " + "stored") + + def action_restore_database(self, copy=False): + """ + Function to restore the database Backups + """ + insecure = odoo.tools.config.verify_admin_password('admin') + if insecure and self.db_master_pwd: + dispatch_rpc('db', 'change_admin_password', + ["admin", self.db_master_pwd]) + try: + db.check_super(self.db_master_pwd) + temp_file = tempfile.NamedTemporaryFile(delete=False) + if self.backup_location == 'Google Drive': + gdown.download(self.db_file, temp_file.name, quiet=False) + elif self.backup_location in ['Dropbox', 'OneDrive']: + response = requests.get(self.db_file, stream=True) + temp_file.write(response.content) + elif self.backup_location == 'FTP Storage': + for rec in self.env['db.backup.configure'].search([]): + if rec.backup_destination == 'ftp' and \ + rec.ftp_path == os.path.dirname(self.db_file): + ftp_server = ftplib.FTP() + ftp_server.connect(rec.ftp_host, int(rec.ftp_port)) + ftp_server.login(rec.ftp_user, rec.ftp_password) + ftp_server.retrbinary("RETR " + self.db_file, + temp_file.write) + temp_file.seek(0) + ftp_server.quit() + elif self.backup_location == 'SFTP Storage': + for rec in self.env['db.backup.configure'].search([]): + if rec.backup_destination == 'sftp' and \ + rec.sftp_path == os.path.dirname(self.db_file): + sftp_client = paramiko.SSHClient() + sftp_client.set_missing_host_key_policy( + paramiko.AutoAddPolicy()) + sftp_client.connect(hostname=rec.sftp_host, + username=rec.sftp_user, + password=rec.sftp_password, + port=rec.sftp_port) + sftp_server = sftp_client.open_sftp() + sftp_server.getfo(self.db_file, temp_file) + sftp_server.close() + sftp_client.close() + elif self.backup_location == 'Local Storage': + temp_file.name = self.db_file + db.restore_db(self.db_name, temp_file.name, str2bool(copy)) + temp_file.close() + return { + 'type': 'ir.actions.act_url', + 'url': '/web/database/manager' + } + except Exception as error: + raise UserError( + _("Database restore error: %s" % (str(error) or repr(error)))) diff --git a/odoo_database_restore_manager/wizard/database_restore_views.xml b/odoo_database_restore_manager/wizard/database_restore_views.xml new file mode 100644 index 000000000..2ef9117c1 --- /dev/null +++ b/odoo_database_restore_manager/wizard/database_restore_views.xml @@ -0,0 +1,24 @@ + + + + + database.restore.view.form + database.restore + +
+ + + + + +
+
+
+