diff --git a/odoo_database_restore_manager/README.rst b/odoo_database_restore_manager/README.rst new file mode 100644 index 000000000..c9de86d04 --- /dev/null +++ b/odoo_database_restore_manager/README.rst @@ -0,0 +1,55 @@ +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +Database Restore Manager +======================== +All the database backups that are stored by module auto_database_backup can be +restored using this module + +Configuration +============= +The auto_database_backup module should be installed +( Here is the link: https://apps.odoo.com/apps/modules/17.0/auto_database_backup/ ) +All the requirements for auto_database_backup module should be installed. + +Installation +============ +- www.odoo.com/documentation/17.0/setup/install.html +- Install our custom addon + +License +------- +General Public License, Version 3 (AGPL v3). +(http://www.gnu.org/licenses/agpl-3.0-standalone.html) + +Company +------- +* `Cybrosys Techno Solutions `__ + +Credits +------- +* Developer: (V16) Aslam A K, + (V17) Sruthi Ranjith + 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..0ae036bab --- /dev/null +++ b/odoo_database_restore_manager/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL 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..7c49c3aa6 --- /dev/null +++ b/odoo_database_restore_manager/__manifest__.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +{ + 'name': "Database Restore Manager", + 'version': "17.0.1.0.0", + 'category': "Extra Tools", + 'summary': """Efficient Database Restore Manager""", + 'description': """The Database Restore Manager allows users to easily + restore and download backups uploaded by the auto_database_backup module, + providing convenient backup management within the platform""", + '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/restore.js', + '/odoo_database_restore_manager/static/src/xml/db_restore_dashboard_templates.xml', + '/odoo_database_restore_manager/static/src/scss/db_restore.scss' + ] + }, + 'external_dependencies': {'python': ['dropbox', 'gdown']}, + 'images': ['static/description/banner.jpg'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} 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..c7afaeb30 --- /dev/null +++ b/odoo_database_restore_manager/doc/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 20.03.2024 +#### Version 17.0.1.0.0 +#### ADD +- Initial commit for 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..78169d9ee --- /dev/null +++ b/odoo_database_restore_manager/models/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL 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..732a46cf9 --- /dev/null +++ b/odoo_database_restore_manager/models/database_manager.py @@ -0,0 +1,279 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +import boto3 +import dropbox +import ftplib +import nextcloud_client +import os +import paramiko +import requests +from odoo.http import request +from datetime import datetime +from odoo import api, fields, models + + +class DatabaseManager(models.Model): + """ Dashboard model to view all database backups """ + _name = 'database.manager' + _description = 'Database Manager' + + @api.model + 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')) + current_company = request.httprequest.cookies.get('cids')[0] + # Check if backup_count is less than or equal to 0 + if backup_count <= 0: + return ['error', 'Please set a backup count', 'Storages', + current_company] + # Check if any backups are configured in the database + if not self.env['db.backup.configure'].search([]): + return ['error', 'No Backups Found', 'auto_database_backup', + current_company] + # Loop through each configured backup source + for rec in self.env['db.backup.configure'].search([]): + # For Dropbox + if rec.backup_destination == 'dropbox': + try: + # Retrieve backups from Dropbox and update the return_data + # dictionary with the latest backups + 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 e: + # Handle any exceptions that occur during Dropbox backup + # retrieval + return ['error', e, 'Dropbox', current_company] + # For Onedrive + if rec.backup_destination == 'onedrive': + try: + # Retrieve backups from OneDrive and update the return_data + # dictionary with the latest backups + 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 e: + # Handle any exceptions that occur during OneDrive backup + # retrieval + return ['error', e, 'OneDrive', current_company] + # For Google Drive + if rec.backup_destination == 'google_drive': + try: + # Retrieve backups from Google Drive and update the + # return_data dictionary with the latest backups + 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 e: + # Handle any exceptions that occur during Google Drive + # backup retrieval + return ['error', e, 'Google Drive', current_company] + # For Local Storage + if rec.backup_destination == 'local': + try: + # Retrieve backups from Local Storage and update the + # return_data dictionary with the latest backups + 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 e: + # Handle any exceptions that occur during Local Storage + # backup retrieval + return ['error', e, 'Local', current_company] + # For FTP + if rec.backup_destination == 'ftp': + try: + # Retrieve backups from FTP Storage and update the + # return_data dictionary with the latest backups + 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 e: + # Handle any exceptions that occur during FTP Storage + # backup retrieval + return ['error', e, 'FTP server', current_company] + # For SFTP + if rec.backup_destination == 'sftp': + sftp_client = paramiko.SSHClient() + sftp_client.set_missing_host_key_policy( + paramiko.AutoAddPolicy()) + try: + # Retrieve backups from SFTP Storage and update the + # return_data dictionary with the latest backups + 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 e: + # Handle any exceptions that occur during SFTP Storage + # backup retrieval + return ['error', e, 'SFTP server', current_company] + finally: + sftp_client.close() + # For Next Cloud + 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', current_company] + # For Amazon S3 + 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', current_company] + + # Return the dictionary containing the latest backups from all + # configured sources + return [return_data, current_company] 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..33d396ffd --- /dev/null +++ b/odoo_database_restore_manager/models/res_config_settings.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL 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/cybro-icon.png b/odoo_database_restore_manager/static/description/assets/cybro-icon.png new file mode 100644 index 000000000..06e73e11d Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/cybro-icon.png differ diff --git a/odoo_database_restore_manager/static/description/assets/cybro-odoo.png b/odoo_database_restore_manager/static/description/assets/cybro-odoo.png new file mode 100644 index 000000000..ed02e07a4 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/cybro-odoo.png differ 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/down.svg b/odoo_database_restore_manager/static/description/assets/icons/down.svg new file mode 100644 index 000000000..f21c36271 --- /dev/null +++ b/odoo_database_restore_manager/static/description/assets/icons/down.svg @@ -0,0 +1 @@ + \ No newline at end of file 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/faq.png b/odoo_database_restore_manager/static/description/assets/icons/faq.png new file mode 100644 index 000000000..4250b5b81 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/faq.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/feature.png b/odoo_database_restore_manager/static/description/assets/icons/feature.png new file mode 100644 index 000000000..ac7a785c0 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/feature.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/notes.png b/odoo_database_restore_manager/static/description/assets/icons/notes.png new file mode 100644 index 000000000..ee5e95404 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/notes.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/screenshot.png b/odoo_database_restore_manager/static/description/assets/icons/screenshot.png new file mode 100644 index 000000000..cef272529 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/screenshot.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/skype.png b/odoo_database_restore_manager/static/description/assets/icons/skype.png new file mode 100644 index 000000000..51b409fb3 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/skype.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/star-1.svg b/odoo_database_restore_manager/static/description/assets/icons/star-1.svg new file mode 100644 index 000000000..7e55ab162 --- /dev/null +++ b/odoo_database_restore_manager/static/description/assets/icons/star-1.svg @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/odoo_database_restore_manager/static/description/assets/icons/star-2.svg b/odoo_database_restore_manager/static/description/assets/icons/star-2.svg new file mode 100644 index 000000000..5ae9f507a --- /dev/null +++ b/odoo_database_restore_manager/static/description/assets/icons/star-2.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/odoo_database_restore_manager/static/description/assets/icons/support.png b/odoo_database_restore_manager/static/description/assets/icons/support.png new file mode 100644 index 000000000..4f18b8b82 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/support.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/test-1 - Copy.png b/odoo_database_restore_manager/static/description/assets/icons/test-1 - Copy.png new file mode 100644 index 000000000..f6a902663 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/test-1 - Copy.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/test-1.png b/odoo_database_restore_manager/static/description/assets/icons/test-1.png new file mode 100644 index 000000000..0908add2b Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/test-1.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/test-2.png b/odoo_database_restore_manager/static/description/assets/icons/test-2.png new file mode 100644 index 000000000..4671fe91e Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/test-2.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/video.png b/odoo_database_restore_manager/static/description/assets/icons/video.png new file mode 100644 index 000000000..576705b17 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/video.png differ diff --git a/odoo_database_restore_manager/static/description/assets/icons/whatsapp.png b/odoo_database_restore_manager/static/description/assets/icons/whatsapp.png new file mode 100644 index 000000000..d513a5356 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/icons/whatsapp.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/Cybrosys R.png b/odoo_database_restore_manager/static/description/assets/misc/Cybrosys R.png new file mode 100644 index 000000000..da4058087 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/misc/Cybrosys R.png differ diff --git a/odoo_database_restore_manager/static/description/assets/misc/email.svg b/odoo_database_restore_manager/static/description/assets/misc/email.svg new file mode 100644 index 000000000..15291cdc3 --- /dev/null +++ b/odoo_database_restore_manager/static/description/assets/misc/email.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/odoo_database_restore_manager/static/description/assets/misc/phone.svg b/odoo_database_restore_manager/static/description/assets/misc/phone.svg new file mode 100644 index 000000000..b7bd7f251 --- /dev/null +++ b/odoo_database_restore_manager/static/description/assets/misc/phone.svg @@ -0,0 +1,3 @@ + + + diff --git a/odoo_database_restore_manager/static/description/assets/misc/star (1) 2.svg b/odoo_database_restore_manager/static/description/assets/misc/star (1) 2.svg new file mode 100644 index 000000000..5ae9f507a --- /dev/null +++ b/odoo_database_restore_manager/static/description/assets/misc/star (1) 2.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/odoo_database_restore_manager/static/description/assets/misc/support (1) 1.svg b/odoo_database_restore_manager/static/description/assets/misc/support (1) 1.svg new file mode 100644 index 000000000..7d37a8f30 --- /dev/null +++ b/odoo_database_restore_manager/static/description/assets/misc/support (1) 1.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/odoo_database_restore_manager/static/description/assets/misc/support-email.svg b/odoo_database_restore_manager/static/description/assets/misc/support-email.svg new file mode 100644 index 000000000..eb70370d6 --- /dev/null +++ b/odoo_database_restore_manager/static/description/assets/misc/support-email.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/odoo_database_restore_manager/static/description/assets/misc/tick-mark.svg b/odoo_database_restore_manager/static/description/assets/misc/tick-mark.svg new file mode 100644 index 000000000..2dbb40187 --- /dev/null +++ b/odoo_database_restore_manager/static/description/assets/misc/tick-mark.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/odoo_database_restore_manager/static/description/assets/misc/whatsapp 1.svg b/odoo_database_restore_manager/static/description/assets/misc/whatsapp 1.svg new file mode 100644 index 000000000..0bfaf8fc6 --- /dev/null +++ b/odoo_database_restore_manager/static/description/assets/misc/whatsapp 1.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/odoo_database_restore_manager/static/description/assets/misc/whatsapp.svg b/odoo_database_restore_manager/static/description/assets/misc/whatsapp.svg new file mode 100644 index 000000000..b618aea1d --- /dev/null +++ b/odoo_database_restore_manager/static/description/assets/misc/whatsapp.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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..ae3a880a2 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.jpg b/odoo_database_restore_manager/static/description/assets/modules/2.jpg new file mode 100644 index 000000000..a1dc39c89 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/modules/2.jpg 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..8513873ea 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..3bedf7981 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..0e311ca87 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.jpg b/odoo_database_restore_manager/static/description/assets/modules/6.jpg new file mode 100644 index 000000000..67c7f7062 Binary files /dev/null and b/odoo_database_restore_manager/static/description/assets/modules/6.jpg 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..fd0253714 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..0c3c7aebd 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..f1673729d 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..efca25db9 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..681e7dd56 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..67195bd06 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..d18ecf81e 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..45b74bb64 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..1931924db 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..0f794ed76 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..e06db2e1e --- /dev/null +++ b/odoo_database_restore_manager/static/description/index.html @@ -0,0 +1,1192 @@ + + + + + + + + Document + + + + + + + + +
+ +
+
+

+ Database Restore Manager +

+

+ This Module Helps To Restore Automated Backup Of Databases.

+
+
+

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

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

+ KEY HIGHLIGHTS +

+
+
+
+
+ +
+
+

+ Simplifies database restoration process

+
+
+
+
+
+
+ +
+
+

Seamlessly restores backups from diverse locations

+
+
+
+
+
+
+ +
+
+

Centralized interface for easy management

+
+
+
+
+
+
+ +
+
+

Easy and Flexible Restoration

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

+ Overview + +

+
+
+
+ The Database Restore Manager streamlines database restoration by + effortlessly restoring backups stored in different locations + through the "auto_database_backup" module. Users can easily + restore Odoo databases from these backups via a centralized + interface, simplifying the entire process. Integrated seamlessly + with "auto_database_backup," the app enables users to schedule and + store regular backups across various options like local directories, + FTP servers, SFTP servers, Google Drive, Dropbox, and OneDrive, + enhancing data protection. +
+
+
+
+ +
+ + +
+
+ +
+ +
+ +
+ +
+
+ +
+

+ Screenshots + +

+

+ Automatic Database Backup.

+
+ +
+

+ Configure backups by + Automatic Database Backup Module. +

+

+ Go to Setting --> Technical --> Backup Configuration + to configure backups.

+
+ +
+
+ +
+

+ 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. +

+
+ +
+
+ +
+

+ Store Backup to Onedrive. +

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

+

+ +
+

+ FEATURES + +

+

+ Comprehensive Features of DATABASE RESTORE MANAGER

+
+ + +
+ +
+
+
+
+ + + +
+ Streamlines the process of restoring databases. +
+
+
+
+
+ +
+
+
+
+ + + +
+ Effortlessly retrieves backups from various locations. +
+
+
+
+
+ +
+
+
+
+ + + +
+ Provides a centralized interface for seamless management.
+
+
+
+
+ +
+
+
+
+ + + +
+ Seamlessly integrates with the "auto_database_backup" module. +
+
+
+
+
+ +
+
+
+
+ + + +
+ Enhances data protection with multiple storage options. +
+
+
+
+
+ +
+
+
+
+ + + +
+ Stores To Remote Servers, + Nextcloud, Amazon S3, Google + Drive, Dropbox, Onedrive. +
+
+
+
+
+ +
+
+
+ +
+ +
+ +
+
+

+ FAQ +

+

+ Current Stock Report for all Products in each + Warehouse.

+
+
+
+
+ + + +
+
+

+ The Database Restore Manager makes restoring + databases easier by offering a user-friendly + interface and automating tasks in the process. +

+
+
+ + + +
+
+

+ The Database Restore Manager effortlessly retrieves + backups from various locations like local directories, + FTP servers, SFTP servers, Google Drive, Dropbox, and OneDrive. +

+
+
+ + + +
+
+

+ The Database Restore Manager's centralized interface + lets users easily manage and monitor database backups + from one place, making management simpler and more streamlined. +

+
+
+ + + +
+
+

+ Integration with the "auto_database_backup" + module ensures smooth coordination between + backup creation and restoration processes, + guaranteeing efficient and reliable database management. +

+
+
+ + + +
+
+

+ The Database Restore Manager automates backup + scheduling and storage by letting users set regular + schedules and choose storage locations, saving time + and ensuring consistent backups. +

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

+ RELEASE NOTES + +

+
+
+
+
+
+

Version 17.0.1 I Released on : 20th March 2024 +

+

Initial commit for odoo_database_restore_manager

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

Related Modules

+

Explore our related modules

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

+ 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? Get in touch. +

+
+
+
+
+
+ +
+
+

Need Help?

+

Got questions or need help? + Get + in touch.

+ +

+ odoo@cybrosys.com

+
+
+
+
+
+
+
+ +
+
+

WhatsApp

+

Say hi to us on + WhatsApp!

+ +

+91 + 86068 + 27707

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

Skype

+

Say hi to us on Skype!

+ +

cybroopenerp

+
+
+
+
+ + +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ + + + + + \ 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/restore.js b/odoo_database_restore_manager/static/src/js/restore.js new file mode 100644 index 000000000..2dbd0cd05 --- /dev/null +++ b/odoo_database_restore_manager/static/src/js/restore.js @@ -0,0 +1,79 @@ +/* @odoo-module */ +import { useService } from "@web/core/utils/hooks"; +import { Component, onWillStart, useState } from "@odoo/owl"; +import {registry} from '@web/core/registry'; + + +export class DbRestoreDashboard extends Component { + setup() { + super.setup(...arguments); + this.dbDashboard = useState({ data: [] }) + this.orm = useService("orm"); + this.action = useService("action"); + onWillStart(async () => { + await this.loadDashboardData(); + }); + } + async loadDashboardData() { + const database_file = await this.orm.call( + 'database.manager', + 'action_import_files', + [] + ); + if (database_file[0] == 'error'){ + this.action.doAction({ + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'message': 'Failed to Load Files from ' + database_file[2] + ' [ ' + database_file[1] + ' ]', + 'type': 'warning', + 'sticky': false, + } + }); + } + else { + this.dbDashboard.data = Object.entries(database_file[0]).map(([file_name, values]) => { + return { + 'file_name': file_name, + 'values': values + }; + }); + } + } +// Function for restore the database + _onClick_restore(ev) { + this.action.doAction({ + 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.value, + default_backup_location: ev.target.dataset.location + }, + target: 'new', + }); + } + isValidBackupName(name) { + return ['Dropbox', 'OneDrive', 'Google Drive' , 'Nextcloud', 'AmazonS3'].includes(name) + } +// Filter for location + _onchange_location(ev) { + var e = ev.target.value + var self = this; + $('.table_row').show(); + $('.table_row').each(function(index, element) { + if (e == 'all_backups') { + $('.table_row').show(); + } + else if ($(element)[0].children[2].innerHTML != e){ + $(element).hide(); + } + }); + }; +} +registry.category("actions").add("database_manager_dashboard", DbRestoreDashboard); +DbRestoreDashboard.components = { DbRestoreDashboard }; +DbRestoreDashboard.template = 'database_manager_dashboard.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..a6313140f --- /dev/null +++ b/odoo_database_restore_manager/static/src/scss/db_restore.scss @@ -0,0 +1,65 @@ +#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: 100px; + background-color: #b1b1b1; + height: 30px; + border: none; + text-transform: capitalize; + margin-right: 10px; + text-align: center; +} +#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; +} +.table-data { + text-align: center; +} +.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_templates.xml b/odoo_database_restore_manager/static/src/xml/db_restore_dashboard_templates.xml new file mode 100644 index 000000000..4af9fba9c --- /dev/null +++ b/odoo_database_restore_manager/static/src/xml/db_restore_dashboard_templates.xml @@ -0,0 +1,84 @@ + + + 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..72f0cf48f --- /dev/null +++ b/odoo_database_restore_manager/views/database_manager_views.xml @@ -0,0 +1,13 @@ + + + + + Database Restore Manager + 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..0095037e9 --- /dev/null +++ b/odoo_database_restore_manager/views/res_config_settings_views.xml @@ -0,0 +1,23 @@ + + + + + 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..ecd7df4ea --- /dev/null +++ b/odoo_database_restore_manager/wizard/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL 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..9aafd6857 --- /dev/null +++ b/odoo_database_restore_manager/wizard/database_restore.py @@ -0,0 +1,115 @@ +# -*- coding: utf-8 -*- +############################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies(). +# Author: Cybrosys Techno Solutions() +# +# You can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# (AGPL v3) along with this program. +# If not, see . +# +############################################################################### +import ftplib +import gdown +import os +import paramiko +import requests +import tempfile +import odoo +import odoo.modules.registry +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 = "Database Restore" + + db_file = fields.Char(string="File", help="Restore database file") + db_name = fields.Char(string="Database Name", help="Name of the database") + db_master_pwd = fields.Char(string="Database Master Password", + help="Master Password to restore database") + backup_location = fields.Char(string="Backup Location", + help="Database backup location") + + def action_restore_database(self, copy=False): + """ Function to restore the database Backup """ + # Check if the admin password is insecure and update it if provided + 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: + # Check if the admin password is correct and proceed with the + # restore process + db.check_super(self.db_master_pwd) + # Create a temporary file to store the downloaded backup data + temp_file = tempfile.NamedTemporaryFile(delete=False) + if self.backup_location == 'Google Drive': + # Retrieve backup from Google Drive using gdown library + gdown.download(self.db_file, temp_file.name, quiet=False) + elif self.backup_location in ['Dropbox', 'OneDrive', 'Nextcloud', 'AmazonS3']: + # Retrieve backup from Dropbox or OneDrive using requests + # library + response = requests.get(self.db_file, stream=True) + temp_file.write(response.content) + elif self.backup_location == 'FTP Storage': + # Retrieve backup from FTP Storage using ftplib + 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': + # Retrieve backup from SFTP Storage using paramiko + 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': + # If the backup is stored in the local storage, set the temp + # file's name accordingly + temp_file.name = self.db_file + # Restore the database using Odoo's 'restore_db' method + db.restore_db(self.db_name, temp_file.name, str2bool(copy)) + temp_file.close() + # Redirect the user to the Database Manager after successful + # restore + return { + 'type': 'ir.actions.act_url', + 'url': '/web/database/manager' + } + except Exception as e: + # Raise a UserError if any error occurs during the database + # restore process + raise UserError( + "Database restore error: %s" % (str(e) or repr(e))) 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 + +
+ + + + + +
+
+
+