diff --git a/auto_database_backup/README.rst b/auto_database_backup/README.rst new file mode 100644 index 000000000..2291439c6 --- /dev/null +++ b/auto_database_backup/README.rst @@ -0,0 +1,43 @@ +Automatic Database Backup To Local Server, Remote Server, Google Drive And Dropbox +================================================================================== +* Generate Database Backups and store to multiple locations + +Installation +============ + - www.odoo.com/documentation/16.0/setup/install.html + - Install our custom addon + +License +------- +General Public License, Version 3 (LGPL v3). +(https://www.odoo.com/documentation/user/16.0/legal/licenses/licenses.html) + +Company +------- +* 'Cybrosys Techno Solutions `__ + +Credits +------- +* Developer: +(v15) Midilaj @ Cybrosys +(v16) Midilaj @ Cybrosys + + +Contacts +-------- +* Mail Contact : odoo@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 +========== +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/auto_database_backup/__init__.py b/auto_database_backup/__init__.py new file mode 100644 index 000000000..abb525ca0 --- /dev/null +++ b/auto_database_backup/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2022-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# 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 +from . import controllers diff --git a/auto_database_backup/__manifest__.py b/auto_database_backup/__manifest__.py new file mode 100644 index 000000000..37cdeba30 --- /dev/null +++ b/auto_database_backup/__manifest__.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2022-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# 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': "Automatic Database Backup To Local Server, Remote Server, Google Drive, Dropbox and Onedrive", + 'version': '16.0.1.0.0', + 'summary': """Generate automatic backup of databases and store to local, google drive, dropbox, onedrive or remote server""", + 'description': """This module has been developed for creating database backups automatically + and store it to the different locations.""", + 'author': "Cybrosys Techno Solutions", + 'website': "https://www.cybrosys.com", + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'category': 'Tools', + 'depends': ['base', 'mail'], + 'data': [ + 'security/ir.model.access.csv', + 'data/data.xml', + 'views/db_backup_configure_views.xml', + 'wizard/authentication_wizard_views.xml', + ], + 'external_dependencies': {'python': ['dropbox']}, + 'license': 'LGPL-3', + 'images': ['static/description/banner.png'], + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/auto_database_backup/controllers/__init__.py b/auto_database_backup/controllers/__init__.py new file mode 100644 index 000000000..8c5dc606f --- /dev/null +++ b/auto_database_backup/controllers/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2022-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# 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 main diff --git a/auto_database_backup/controllers/main.py b/auto_database_backup/controllers/main.py new file mode 100644 index 000000000..f0c42adcf --- /dev/null +++ b/auto_database_backup/controllers/main.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2022-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# 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 json + +from odoo import http +from odoo.http import request + + +class OnedriveAuth(http.Controller): + + @http.route('/onedrive/authentication', type='http', auth="public") + def oauth2callback(self, **kw): + state = json.loads(kw['state']) + backup_config = request.env['db.backup.configure'].sudo().browse(state.get('backup_config_id')) + backup_config.get_onedrive_tokens(kw.get('code')) + url_return = state.get('url_return') + return request.redirect(url_return) + + @http.route('/google_drive/authentication', type='http', auth="public") + def gdrive_oauth2callback(self, **kw): + state = json.loads(kw['state']) + backup_config = request.env['db.backup.configure'].sudo().browse(state.get('backup_config_id')) + backup_config.get_gdrive_tokens(kw.get('code')) + url_return = state.get('url_return') + return request.redirect(url_return) diff --git a/auto_database_backup/data/data.xml b/auto_database_backup/data/data.xml new file mode 100644 index 000000000..e12b37942 --- /dev/null +++ b/auto_database_backup/data/data.xml @@ -0,0 +1,182 @@ + + + + + + + + Backup : Automatic Database Backup + + code + model._schedule_auto_backup() + 1 + days + -1 + False + + + + + + + + Database Backup: Notification Successful + + Database Backup Successful: {{ object.db_name }} + {{ object.user_id.email_formatted }} + +
+

+ Dear , + +
+
+ Backup of the database + + + + has been successfully generated and stored to + + Local + + + Google Drive + + + FTP Server + + + SFTP Server + + + Dropbox + + + Onedrive + + . +
+
+ Database Name: + +
+ Destination: + + Local + + + Google Drive + + + FTP Server + + + SFTP Server + + + Dropbox + + + Onedrive + + +
+ Backup Path: + + + + + + + + + + + + + +
+ Backup Type: + +
+ Backup FileName: + +
+

+
+
+
+ + + + Database Backup: Notification Failed + + Database Backup Failed: {{ object.db_name }} + {{ object.user_id.email_formatted }} + +
+

+ Dear , + +
+
+ Backup generation of the database + + + + has been Failed. +
+
+ Database Name: +
+ Destination: + + Local + + + Google Drive + + + FTP Server + + + SFTP Server + + + Dropbox + + + Onedrive + + +
+ Backup Path: + + + + + + + + + + + + + +
+ Backup Type: +
+
+ Error Message: +
+ +
+

+
+
+
+
+ + +
\ No newline at end of file diff --git a/auto_database_backup/doc/RELEASE_NOTES.md b/auto_database_backup/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..5dd5cda2e --- /dev/null +++ b/auto_database_backup/doc/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 31.10.2022 +#### Version 16.0.1.0.0 +#### ADD +- Initial commit for auto_database_backup diff --git a/auto_database_backup/models/__init__.py b/auto_database_backup/models/__init__.py new file mode 100644 index 000000000..f71ffa785 --- /dev/null +++ b/auto_database_backup/models/__init__.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2022-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# 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 db_backup_configure diff --git a/auto_database_backup/models/db_backup_configure.py b/auto_database_backup/models/db_backup_configure.py new file mode 100644 index 000000000..a7774e8be --- /dev/null +++ b/auto_database_backup/models/db_backup_configure.py @@ -0,0 +1,590 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2022-TODAY Cybrosys Technologies() +# Author: Cybrosys Techno Solutions() +# +# 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 models, fields, api, _ +from odoo.exceptions import UserError, ValidationError +import odoo +from odoo.service import db +from odoo.http import request + +import dropbox + +from werkzeug import urls +from datetime import timedelta + +import datetime +import os +import paramiko +import ftplib +import json +import requests +import tempfile +import errno +import logging + +_logger = logging.getLogger(__name__) + +ONEDRIVE_SCOPE = ['offline_access openid Files.ReadWrite.All'] +MICROSOFT_GRAPH_END_POINT = "https://graph.microsoft.com" +GOOGLE_AUTH_ENDPOINT = 'https://accounts.google.com/o/oauth2/auth' +GOOGLE_TOKEN_ENDPOINT = 'https://accounts.google.com/o/oauth2/token' +GOOGLE_API_BASE_URL = 'https://www.googleapis.com' + + +class AutoDatabaseBackup(models.Model): + _name = 'db.backup.configure' + _description = 'Automatic Database Backup' + + name = fields.Char(string='Name', required=True) + db_name = fields.Char(string='Database Name', required=True) + master_pwd = fields.Char(string='Master Password', required=True) + backup_format = fields.Selection([ + ('zip', 'Zip'), + ('dump', 'Dump') + ], string='Backup Format', default='zip', required=True) + backup_destination = fields.Selection([ + ('local', 'Local Storage'), + ('google_drive', 'Google Drive'), + ('ftp', 'FTP'), + ('sftp', 'SFTP'), + ('dropbox', 'Dropbox'), + ('onedrive', 'Onedrive') + ], string='Backup Destination') + backup_path = fields.Char(string='Backup Path', help='Local storage directory path') + sftp_host = fields.Char(string='SFTP Host') + sftp_port = fields.Char(string='SFTP Port', default=22) + sftp_user = fields.Char(string='SFTP User', copy=False) + sftp_password = fields.Char(string='SFTP Password', copy=False) + sftp_path = fields.Char(string='SFTP Path') + ftp_host = fields.Char(string='FTP Host') + ftp_port = fields.Char(string='FTP Port', default=21) + ftp_user = fields.Char(string='FTP User', copy=False) + ftp_password = fields.Char(string='FTP Password', copy=False) + ftp_path = fields.Char(string='FTP Path') + dropbox_client_id = fields.Char(string='Dropbox Client ID', copy=False) + dropbox_client_secret = fields.Char(string='Dropbox Client Secret', copy=False) + dropbox_refresh_token = fields.Char(string='Dropbox Refresh Token', copy=False) + is_dropbox_token_generated = fields.Boolean(string='Dropbox Token Generated', compute='_compute_is_dropbox_token_generated', copy=False) + dropbox_folder = fields.Char('Dropbox Folder') + active = fields.Boolean(default=True) + auto_remove = fields.Boolean(string='Remove Old Backups') + days_to_remove = fields.Integer(string='Remove After', + help='Automatically delete stored backups after this specified number of days') + google_drive_folderid = fields.Char(string='Drive Folder ID') + notify_user = fields.Boolean(string='Notify User', + help='Send an email notification to user when the backup operation is successful or failed') + user_id = fields.Many2one('res.users', string='User') + backup_filename = fields.Char(string='Backup Filename', help='For Storing generated backup filename') + generated_exception = fields.Char(string='Exception', help='Exception Encountered while Backup generation') + onedrive_client_id = fields.Char(string='Onedrive Client ID', copy=False) + onedrive_client_secret = fields.Char(string='Onedrive Client Secret', copy=False) + onedrive_access_token = fields.Char(string='Onedrive Access Token', copy=False) + onedrive_refresh_token = fields.Char(string='Onedrive Refresh Token', copy=False) + onedrive_token_validity = fields.Datetime(string='Onedrive Token Validity', copy=False) + onedrive_folder_id = fields.Char(string='Folder ID') + is_onedrive_token_generated = fields.Boolean(string='onedrive Tokens Generated', + compute='_compute_is_onedrive_token_generated', copy=False) + gdrive_refresh_token = fields.Char(string='Google drive Refresh Token', copy=False) + gdrive_access_token = fields.Char(string='Google Drive Access Token', copy=False) + is_google_drive_token_generated = fields.Boolean(string='Google drive Token Generated', + compute='_compute_is_google_drive_token_generated', copy=False) + gdrive_client_id = fields.Char(string='Google Drive Client ID', copy=False) + gdrive_client_secret = fields.Char(string='Google Drive Client Secret', copy=False) + gdrive_token_validity = fields.Datetime(string='Google Drive Token Validity', copy=False) + onedrive_redirect_uri = fields.Char(string='Onedrive Redirect URI', compute='_compute_redirect_uri') + gdrive_redirect_uri = fields.Char(string='Google Drive Redirect URI', compute='_compute_redirect_uri') + + def _compute_redirect_uri(self): + for rec in self: + base_url = request.env['ir.config_parameter'].get_param('web.base.url') + rec.onedrive_redirect_uri = base_url + '/onedrive/authentication' + rec.gdrive_redirect_uri = base_url + '/google_drive/authentication' + + @api.depends('onedrive_access_token', 'onedrive_refresh_token') + def _compute_is_onedrive_token_generated(self): + """ + Set true if onedrive tokens are generated + """ + for rec in self: + rec.is_onedrive_token_generated = bool(rec.onedrive_access_token) and bool(rec.onedrive_refresh_token) + + @api.depends('dropbox_refresh_token') + def _compute_is_dropbox_token_generated(self): + """ + Set True if the dropbox refresh token is generated + """ + for rec in self: + rec.is_dropbox_token_generated = bool(rec.dropbox_refresh_token) + + @api.depends('gdrive_access_token', 'gdrive_refresh_token') + def _compute_is_google_drive_token_generated(self): + """ + Set True if the Google Drive refresh token is generated + """ + for rec in self: + rec.is_google_drive_token_generated = bool(rec.gdrive_access_token) and bool(rec.gdrive_refresh_token) + + def action_get_dropbox_auth_code(self): + """ + Open a wizard to set up dropbox Authorization code + """ + return { + 'type': 'ir.actions.act_window', + 'name': 'Dropbox Authorization Wizard', + 'res_model': 'authentication.wizard', + 'view_mode': 'form', + 'target': 'new', + 'context': {'dropbox_auth': True} + } + + def action_get_onedrive_auth_code(self): + """ + Generate onedrive authorization code + """ + AUTHORITY = 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize' + action = self.env["ir.actions.act_window"].sudo()._for_xml_id("auto_database_backup.action_db_backup_configure") + base_url = request.env['ir.config_parameter'].get_param('web.base.url') + url_return = base_url + '/web#id=%d&action=%d&view_type=form&model=%s' % (self.id, action['id'], 'db.backup.configure') + state = { + 'backup_config_id': self.id, + 'url_return': url_return + } + encoded_params = urls.url_encode({ + 'response_type': 'code', + 'client_id': self.onedrive_client_id, + 'state': json.dumps(state), + 'scope': ONEDRIVE_SCOPE, + 'redirect_uri': base_url + '/onedrive/authentication', + 'prompt': 'consent', + 'access_type': 'offline' + }) + auth_url = "%s?%s" % (AUTHORITY, encoded_params) + return { + 'type': 'ir.actions.act_url', + 'target': 'self', + 'url': auth_url, + } + + def action_get_gdrive_auth_code(self): + """ + Generate ogoogle drive authorization code + """ + action = self.env["ir.actions.act_window"].sudo()._for_xml_id("auto_database_backup.action_db_backup_configure") + base_url = request.env['ir.config_parameter'].get_param('web.base.url') + url_return = base_url + '/web#id=%d&action=%d&view_type=form&model=%s' % (self.id, action['id'], 'db.backup.configure') + state = { + 'backup_config_id': self.id, + 'url_return': url_return + } + encoded_params = urls.url_encode({ + 'response_type': 'code', + 'client_id': self.gdrive_client_id, + 'scope': 'https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/drive.file', + 'redirect_uri': base_url + '/google_drive/authentication', + 'access_type': 'offline', + 'state': json.dumps(state), + 'approval_prompt': 'force', + }) + auth_url = "%s?%s" % (GOOGLE_AUTH_ENDPOINT, encoded_params) + return { + 'type': 'ir.actions.act_url', + 'target': 'self', + 'url': auth_url, + } + + def generate_onedrive_refresh_token(self): + """ + generate onedrive access token from refresh token if expired + """ + base_url = request.env['ir.config_parameter'].get_param('web.base.url') + headers = {"Content-type": "application/x-www-form-urlencoded"} + data = { + 'client_id': self.onedrive_client_id, + 'client_secret': self.onedrive_client_secret, + 'scope': ONEDRIVE_SCOPE, + 'grant_type': "refresh_token", + 'redirect_uri': base_url + '/onedrive/authentication', + 'refresh_token': self.onedrive_refresh_token + } + try: + res = requests.post("https://login.microsoftonline.com/common/oauth2/v2.0/token", data=data, headers=headers) + res.raise_for_status() + response = res.content and res.json() or {} + if response: + expires_in = response.get('expires_in') + self.write({ + 'onedrive_access_token': response.get('access_token'), + 'onedrive_refresh_token': response.get('refresh_token'), + 'onedrive_token_validity': fields.Datetime.now() + timedelta(seconds=expires_in) if expires_in else False, + }) + except requests.HTTPError as error: + _logger.exception("Bad microsoft onedrive request : %s !", error.response.content) + raise error + + def get_onedrive_tokens(self, authorize_code): + """ + Generate onedrive tokens from authorization code + """ + headers = {"content-type": "application/x-www-form-urlencoded"} + base_url = request.env['ir.config_parameter'].get_param('web.base.url') + data = { + 'code': authorize_code, + 'client_id': self.onedrive_client_id, + 'client_secret': self.onedrive_client_secret, + 'grant_type': 'authorization_code', + 'scope': ONEDRIVE_SCOPE, + 'redirect_uri': base_url + '/onedrive/authentication' + } + try: + res = requests.post("https://login.microsoftonline.com/common/oauth2/v2.0/token", data=data, headers=headers) + res.raise_for_status() + response = res.content and res.json() or {} + if response: + expires_in = response.get('expires_in') + self.write({ + 'onedrive_access_token': response.get('access_token'), + 'onedrive_refresh_token': response.get('refresh_token'), + 'onedrive_token_validity': fields.Datetime.now() + timedelta(seconds=expires_in) if expires_in else False, + }) + except requests.HTTPError as error: + _logger.exception("Bad microsoft onedrive request : %s !", error.response.content) + raise error + + def generate_gdrive_refresh_token(self): + """ + generate google drive access token from refresh token if expired + """ + headers = {"content-type": "application/x-www-form-urlencoded"} + data = { + 'refresh_token': self.gdrive_refresh_token, + 'client_id': self.gdrive_client_id, + 'client_secret': self.gdrive_client_secret, + 'grant_type': 'refresh_token', + } + try: + res = requests.post(GOOGLE_TOKEN_ENDPOINT, data=data, headers=headers) + res.raise_for_status() + response = res.content and res.json() or {} + if response: + expires_in = response.get('expires_in') + self.write({ + 'gdrive_access_token': response.get('access_token'), + 'gdrive_token_validity': fields.Datetime.now() + timedelta(seconds=expires_in) if expires_in else False, + }) + except requests.HTTPError as error: + error_key = error.response.json().get("error", "nc") + error_msg = _( + "An error occurred while generating the token. Your authorization code may be invalid or has already expired [%s]. " + "You should check your Client ID and secret on the Google APIs plateform or try to stop and restart your calendar synchronisation.", + error_key) + raise UserError(error_msg) + + def get_gdrive_tokens(self, authorize_code): + """ + Generate onedrive tokens from authorization code + """ + + base_url = request.env['ir.config_parameter'].get_param('web.base.url') + + headers = {"content-type": "application/x-www-form-urlencoded"} + data = { + 'code': authorize_code, + 'client_id': self.gdrive_client_id, + 'client_secret': self.gdrive_client_secret, + 'grant_type': 'authorization_code', + 'redirect_uri': base_url + '/google_drive/authentication' + } + try: + res = requests.post(GOOGLE_TOKEN_ENDPOINT, params=data, + headers=headers) + res.raise_for_status() + response = res.content and res.json() or {} + if response: + expires_in = response.get('expires_in') + self.write({ + 'gdrive_access_token': response.get('access_token'), + 'gdrive_refresh_token': response.get('refresh_token'), + 'gdrive_token_validity': fields.Datetime.now() + timedelta( + seconds=expires_in) if expires_in else False, + }) + except requests.HTTPError: + error_msg = _("Something went wrong during your token generation. Maybe your Authorization Code is invalid") + raise UserError(error_msg) + + def get_dropbox_auth_url(self): + """ + Return dropbox authorization url + """ + dbx_auth = dropbox.oauth.DropboxOAuth2FlowNoRedirect(self.dropbox_client_id, self.dropbox_client_secret, + token_access_type='offline') + auth_url = dbx_auth.start() + return auth_url + + def set_dropbox_refresh_token(self, auth_code): + """ + Generate and set the dropbox refresh token from authorization code + + """ + dbx_auth = dropbox.oauth.DropboxOAuth2FlowNoRedirect(self.dropbox_client_id, self.dropbox_client_secret, + token_access_type='offline') + outh_result = dbx_auth.finish(auth_code) + self.dropbox_refresh_token = outh_result.refresh_token + + @api.constrains('db_name') + def _check_db_credentials(self): + """ + Validate entered database name and master password + """ + database_list = db.list_dbs() + if self.db_name not in database_list: + raise ValidationError(_("Invalid Database Name!")) + try: + odoo.service.db.check_super(self.master_pwd) + except Exception: + raise ValidationError(_("Invalid Master Password!")) + + def test_connection(self): + """ + Test the sftp and ftp connection using entered credentials + """ + if self.backup_destination == 'sftp': + client = paramiko.SSHClient() + client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + try: + client.connect(hostname=self.sftp_host, username=self.sftp_user, password=self.sftp_password, port=self.sftp_port) + sftp = client.open_sftp() + sftp.close() + except Exception as e: + raise UserError(_("SFTP Exception: %s", e)) + finally: + client.close() + elif self.backup_destination == 'ftp': + try: + ftp_server = ftplib.FTP() + ftp_server.connect(self.ftp_host, int(self.ftp_port)) + ftp_server.login(self.ftp_user, self.ftp_password) + ftp_server.quit() + except Exception as e: + raise UserError(_("FTP Exception: %s", e)) + title = _("Connection Test Succeeded!") + message = _("Everything seems properly set up!") + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'title': title, + 'message': message, + 'sticky': False, + } + } + + def _schedule_auto_backup(self): + """ + Function for generating and storing backup + Database backup for all the active records in backup configuration model will be created + """ + records = self.search([]) + mail_template_success = self.env.ref('auto_database_backup.mail_template_data_db_backup_successful') + mail_template_failed = self.env.ref('auto_database_backup.mail_template_data_db_backup_failed') + for rec in records: + backup_time = datetime.datetime.utcnow().strftime("%Y-%m-%d_%H-%M-%S") + backup_filename = "%s_%s.%s" % (rec.db_name, backup_time, rec.backup_format) + rec.backup_filename = backup_filename + # Local backup + if rec.backup_destination == 'local': + try: + if not os.path.isdir(rec.backup_path): + os.makedirs(rec.backup_path) + backup_file = os.path.join(rec.backup_path, backup_filename) + f = open(backup_file, "wb") + odoo.service.db.dump_db(rec.db_name, f, rec.backup_format) + f.close() + # remove older backups + if rec.auto_remove: + for filename in os.listdir(rec.backup_path): + file = os.path.join(rec.backup_path, filename) + create_time = datetime.datetime.fromtimestamp(os.path.getctime(file)) + backup_duration = datetime.datetime.utcnow() - create_time + if backup_duration.days >= rec.days_to_remove: + os.remove(file) + if rec.notify_user: + mail_template_success.send_mail(rec.id, force_send=True) + except Exception as e: + rec.generated_exception = e + _logger.info('FTP Exception: %s', e) + if rec.notify_user: + mail_template_failed.send_mail(rec.id, force_send=True) + # FTP backup + elif rec.backup_destination == 'ftp': + try: + 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.encoding = "utf-8" + temp = tempfile.NamedTemporaryFile(suffix='.%s' % rec.backup_format) + try: + ftp_server.cwd(rec.ftp_path) + except ftplib.error_perm: + ftp_server.mkd(rec.ftp_path) + ftp_server.cwd(rec.ftp_path) + with open(temp.name, "wb+") as tmp: + odoo.service.db.dump_db(rec.db_name, tmp, rec.backup_format) + ftp_server.storbinary('STOR %s' % backup_filename, open(temp.name, "rb")) + if rec.auto_remove: + files = ftp_server.nlst() + for f in files: + create_time = datetime.datetime.strptime(ftp_server.sendcmd('MDTM ' + f)[4:], "%Y%m%d%H%M%S") + diff_days = (datetime.datetime.now() - create_time).days + if diff_days >= rec.days_to_remove: + ftp_server.delete(f) + ftp_server.quit() + if rec.notify_user: + mail_template_success.send_mail(rec.id, force_send=True) + except Exception as e: + rec.generated_exception = e + _logger.info('FTP Exception: %s', e) + if rec.notify_user: + mail_template_failed.send_mail(rec.id, force_send=True) + # SFTP backup + elif rec.backup_destination == 'sftp': + client = paramiko.SSHClient() + client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + try: + client.connect(hostname=rec.sftp_host, username=rec.sftp_user, password=rec.sftp_password, port=rec.sftp_port) + sftp = client.open_sftp() + temp = tempfile.NamedTemporaryFile(suffix='.%s' % rec.backup_format) + with open(temp.name, "wb+") as tmp: + odoo.service.db.dump_db(rec.db_name, tmp, rec.backup_format) + try: + sftp.chdir(rec.sftp_path) + except IOError as e: + if e.errno == errno.ENOENT: + sftp.mkdir(rec.sftp_path) + sftp.chdir(rec.sftp_path) + sftp.put(temp.name, backup_filename) + if rec.auto_remove: + files = sftp.listdir() + expired = list(filter(lambda fl: (datetime.datetime.now() - datetime.datetime.fromtimestamp(sftp.stat(fl).st_mtime)).days >= rec.days_to_remove, files)) + for file in expired: + sftp.unlink(file) + sftp.close() + if rec.notify_user: + mail_template_success.send_mail(rec.id, force_send=True) + except Exception as e: + rec.generated_exception = e + _logger.info('SFTP Exception: %s', e) + if rec.notify_user: + mail_template_failed.send_mail(rec.id, force_send=True) + finally: + client.close() + # Google Drive backup + elif rec.backup_destination == 'google_drive': + if rec.gdrive_token_validity <= fields.Datetime.now(): + rec.generate_gdrive_refresh_token() + temp = tempfile.NamedTemporaryFile(suffix='.%s' % rec.backup_format) + with open(temp.name, "wb+") as tmp: + odoo.service.db.dump_db(rec.db_name, tmp, rec.backup_format) + try: + # access_token = self.env['google.drive.config'].sudo().get_access_token() + headers = {"Authorization": "Bearer %s" % rec.gdrive_access_token} + para = { + "name": backup_filename, + "parents": [rec.google_drive_folderid], + } + files = { + 'data': ('metadata', json.dumps(para), 'application/json; charset=UTF-8'), + 'file': open(temp.name, "rb") + } + requests.post( + "https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart", + headers=headers, + files=files + ) + if rec.auto_remove: + query = "parents = '%s'" % rec.google_drive_folderid + files_req = requests.get("https://www.googleapis.com/drive/v3/files?q=%s" % query, headers=headers) + files = files_req.json()['files'] + for file in files: + file_date_req = requests.get("https://www.googleapis.com/drive/v3/files/%s?fields=createdTime" % file['id'], headers=headers) + create_time = file_date_req.json()['createdTime'][:19].replace('T', ' ') + diff_days = (datetime.datetime.now() - datetime.datetime.strptime(create_time, '%Y-%m-%d %H:%M:%S')).days + if diff_days >= rec.days_to_remove: + requests.delete("https://www.googleapis.com/drive/v3/files/%s" % file['id'], headers=headers) + if rec.notify_user: + mail_template_success.send_mail(rec.id, force_send=True) + except Exception as e: + rec.generated_exception = e + _logger.info('Google Drive Exception: %s', e) + if rec.notify_user: + mail_template_failed.send_mail(rec.id, force_send=True) + # Dropbox backup + elif rec.backup_destination == 'dropbox': + temp = tempfile.NamedTemporaryFile(suffix='.%s' % rec.backup_format) + with open(temp.name, "wb+") as tmp: + odoo.service.db.dump_db(rec.db_name, tmp, rec.backup_format) + try: + dbx = dropbox.Dropbox(app_key=rec.dropbox_client_id, app_secret=rec.dropbox_client_secret, oauth2_refresh_token=rec.dropbox_refresh_token) + dropbox_destination = rec.dropbox_folder + '/' + backup_filename + dbx.files_upload(temp.read(), dropbox_destination) + if rec.auto_remove: + files = dbx.files_list_folder(rec.dropbox_folder) + file_entries = files.entries + expired_files = list(filter(lambda fl: (datetime.datetime.now() - fl.client_modified).days >= rec.days_to_remove, file_entries)) + for file in expired_files: + dbx.files_delete_v2(file.path_display) + if rec.notify_user: + mail_template_success.send_mail(rec.id, force_send=True) + except Exception as error: + rec.generated_exception = error + _logger.info('Dropbox Exception: %s', error) + if rec.notify_user: + mail_template_failed.send_mail(rec.id, force_send=True) + # Onedrive Backup + elif rec.backup_destination == 'onedrive': + if rec.onedrive_token_validity <= fields.Datetime.now(): + rec.generate_onedrive_refresh_token() + temp = tempfile.NamedTemporaryFile(suffix='.%s' % rec.backup_format) + with open(temp.name, "wb+") as tmp: + odoo.service.db.dump_db(rec.db_name, tmp, rec.backup_format) + headers = {'Authorization': 'Bearer %s' % rec.onedrive_access_token, 'Content-Type': 'application/json'} + upload_session_url = MICROSOFT_GRAPH_END_POINT + "/v1.0/me/drive/items/%s:/%s:/createUploadSession" % (rec.onedrive_folder_id, backup_filename) + try: + upload_session = requests.post(upload_session_url, headers=headers) + upload_url = upload_session.json().get('uploadUrl') + requests.put(upload_url, data=temp.read()) + if rec.auto_remove: + list_url = MICROSOFT_GRAPH_END_POINT + "/v1.0/me/drive/items/%s/children" % rec.onedrive_folder_id + response = requests.get(list_url, headers=headers) + files = response.json().get('value') + for file in files: + create_time = file['createdDateTime'][:19].replace('T', ' ') + diff_days = (datetime.datetime.now() - datetime.datetime.strptime(create_time, '%Y-%m-%d %H:%M:%S')).days + if diff_days >= rec.days_to_remove: + delete_url = MICROSOFT_GRAPH_END_POINT + "/v1.0/me/drive/items/%s" % file['id'] + requests.delete(delete_url, headers=headers) + if rec.notify_user: + mail_template_success.send_mail(rec.id, force_send=True) + except Exception as error: + rec.generated_exception = error + _logger.info('Onedrive Exception: %s', error) + if rec.notify_user: + mail_template_failed.send_mail(rec.id, force_send=True) diff --git a/auto_database_backup/security/ir.model.access.csv b/auto_database_backup/security/ir.model.access.csv new file mode 100644 index 000000000..04e607dab --- /dev/null +++ b/auto_database_backup/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_db_backup_configure,access.db.backup.configure,model_db_backup_configure,base.group_user,1,1,1,1 +access_authentication_wizard,access.authentication.wizard,model_authentication_wizard,base.group_user,1,1,1,1 \ No newline at end of file diff --git a/auto_database_backup/static/description/assets/icons/check.png b/auto_database_backup/static/description/assets/icons/check.png new file mode 100644 index 000000000..c8e85f51d Binary files /dev/null and b/auto_database_backup/static/description/assets/icons/check.png differ diff --git a/auto_database_backup/static/description/assets/icons/chevron.png b/auto_database_backup/static/description/assets/icons/chevron.png new file mode 100644 index 000000000..2089293d6 Binary files /dev/null and b/auto_database_backup/static/description/assets/icons/chevron.png differ diff --git a/auto_database_backup/static/description/assets/icons/cogs.png b/auto_database_backup/static/description/assets/icons/cogs.png new file mode 100644 index 000000000..95d0bad62 Binary files /dev/null and b/auto_database_backup/static/description/assets/icons/cogs.png differ diff --git a/auto_database_backup/static/description/assets/icons/consultation.png b/auto_database_backup/static/description/assets/icons/consultation.png new file mode 100644 index 000000000..8319d4baa Binary files /dev/null and b/auto_database_backup/static/description/assets/icons/consultation.png differ diff --git a/auto_database_backup/static/description/assets/icons/ecom-black.png b/auto_database_backup/static/description/assets/icons/ecom-black.png new file mode 100644 index 000000000..a9385ff13 Binary files /dev/null and b/auto_database_backup/static/description/assets/icons/ecom-black.png differ diff --git a/auto_database_backup/static/description/assets/icons/education-black.png b/auto_database_backup/static/description/assets/icons/education-black.png new file mode 100644 index 000000000..3eb09b27b Binary files /dev/null and b/auto_database_backup/static/description/assets/icons/education-black.png differ diff --git a/auto_database_backup/static/description/assets/icons/hotel-black.png b/auto_database_backup/static/description/assets/icons/hotel-black.png new file mode 100644 index 000000000..130f613be Binary files /dev/null and b/auto_database_backup/static/description/assets/icons/hotel-black.png differ diff --git a/auto_database_backup/static/description/assets/icons/license.png b/auto_database_backup/static/description/assets/icons/license.png new file mode 100644 index 000000000..a5869797e Binary files /dev/null and b/auto_database_backup/static/description/assets/icons/license.png differ diff --git a/auto_database_backup/static/description/assets/icons/lifebuoy.png b/auto_database_backup/static/description/assets/icons/lifebuoy.png new file mode 100644 index 000000000..658d56ccc Binary files /dev/null and b/auto_database_backup/static/description/assets/icons/lifebuoy.png differ diff --git a/auto_database_backup/static/description/assets/icons/manufacturing-black.png b/auto_database_backup/static/description/assets/icons/manufacturing-black.png new file mode 100644 index 000000000..697eb0e9f Binary files /dev/null and b/auto_database_backup/static/description/assets/icons/manufacturing-black.png differ diff --git a/auto_database_backup/static/description/assets/icons/pos-black.png b/auto_database_backup/static/description/assets/icons/pos-black.png new file mode 100644 index 000000000..97c0f90c1 Binary files /dev/null and b/auto_database_backup/static/description/assets/icons/pos-black.png differ diff --git a/auto_database_backup/static/description/assets/icons/puzzle.png b/auto_database_backup/static/description/assets/icons/puzzle.png new file mode 100644 index 000000000..65cf854e7 Binary files /dev/null and b/auto_database_backup/static/description/assets/icons/puzzle.png differ diff --git a/auto_database_backup/static/description/assets/icons/restaurant-black.png b/auto_database_backup/static/description/assets/icons/restaurant-black.png new file mode 100644 index 000000000..4a35eb939 Binary files /dev/null and b/auto_database_backup/static/description/assets/icons/restaurant-black.png differ diff --git a/auto_database_backup/static/description/assets/icons/service-black.png b/auto_database_backup/static/description/assets/icons/service-black.png new file mode 100644 index 000000000..301ab51cb Binary files /dev/null and b/auto_database_backup/static/description/assets/icons/service-black.png differ diff --git a/auto_database_backup/static/description/assets/icons/trading-black.png b/auto_database_backup/static/description/assets/icons/trading-black.png new file mode 100644 index 000000000..9398ba2f1 Binary files /dev/null and b/auto_database_backup/static/description/assets/icons/trading-black.png differ diff --git a/auto_database_backup/static/description/assets/icons/training.png b/auto_database_backup/static/description/assets/icons/training.png new file mode 100644 index 000000000..884ca024d Binary files /dev/null and b/auto_database_backup/static/description/assets/icons/training.png differ diff --git a/auto_database_backup/static/description/assets/icons/update.png b/auto_database_backup/static/description/assets/icons/update.png new file mode 100644 index 000000000..ecbc5a01a Binary files /dev/null and b/auto_database_backup/static/description/assets/icons/update.png differ diff --git a/auto_database_backup/static/description/assets/icons/user.png b/auto_database_backup/static/description/assets/icons/user.png new file mode 100644 index 000000000..6ffb23d9f Binary files /dev/null and b/auto_database_backup/static/description/assets/icons/user.png differ diff --git a/auto_database_backup/static/description/assets/icons/wrench.png b/auto_database_backup/static/description/assets/icons/wrench.png new file mode 100644 index 000000000..6c04dea0f Binary files /dev/null and b/auto_database_backup/static/description/assets/icons/wrench.png differ diff --git a/auto_database_backup/static/description/assets/misc/categories.png b/auto_database_backup/static/description/assets/misc/categories.png new file mode 100644 index 000000000..bedf1e0b1 Binary files /dev/null and b/auto_database_backup/static/description/assets/misc/categories.png differ diff --git a/auto_database_backup/static/description/assets/misc/check-box.png b/auto_database_backup/static/description/assets/misc/check-box.png new file mode 100644 index 000000000..42caf24b9 Binary files /dev/null and b/auto_database_backup/static/description/assets/misc/check-box.png differ diff --git a/auto_database_backup/static/description/assets/misc/compass.png b/auto_database_backup/static/description/assets/misc/compass.png new file mode 100644 index 000000000..d5fed8faa Binary files /dev/null and b/auto_database_backup/static/description/assets/misc/compass.png differ diff --git a/auto_database_backup/static/description/assets/misc/corporate.png b/auto_database_backup/static/description/assets/misc/corporate.png new file mode 100644 index 000000000..2eb13edbf Binary files /dev/null and b/auto_database_backup/static/description/assets/misc/corporate.png differ diff --git a/auto_database_backup/static/description/assets/misc/customer-support.png b/auto_database_backup/static/description/assets/misc/customer-support.png new file mode 100644 index 000000000..79efc72ed Binary files /dev/null and b/auto_database_backup/static/description/assets/misc/customer-support.png differ diff --git a/auto_database_backup/static/description/assets/misc/cybrosys-logo.png b/auto_database_backup/static/description/assets/misc/cybrosys-logo.png new file mode 100644 index 000000000..cc3cc0ccf Binary files /dev/null and b/auto_database_backup/static/description/assets/misc/cybrosys-logo.png differ diff --git a/auto_database_backup/static/description/assets/misc/features.png b/auto_database_backup/static/description/assets/misc/features.png new file mode 100644 index 000000000..b41769f77 Binary files /dev/null and b/auto_database_backup/static/description/assets/misc/features.png differ diff --git a/auto_database_backup/static/description/assets/misc/logo.png b/auto_database_backup/static/description/assets/misc/logo.png new file mode 100644 index 000000000..478462d3e Binary files /dev/null and b/auto_database_backup/static/description/assets/misc/logo.png differ diff --git a/auto_database_backup/static/description/assets/misc/pictures.png b/auto_database_backup/static/description/assets/misc/pictures.png new file mode 100644 index 000000000..56d255fe9 Binary files /dev/null and b/auto_database_backup/static/description/assets/misc/pictures.png differ diff --git a/auto_database_backup/static/description/assets/misc/pie-chart.png b/auto_database_backup/static/description/assets/misc/pie-chart.png new file mode 100644 index 000000000..426e05244 Binary files /dev/null and b/auto_database_backup/static/description/assets/misc/pie-chart.png differ diff --git a/auto_database_backup/static/description/assets/misc/right-arrow.png b/auto_database_backup/static/description/assets/misc/right-arrow.png new file mode 100644 index 000000000..730984a06 Binary files /dev/null and b/auto_database_backup/static/description/assets/misc/right-arrow.png differ diff --git a/auto_database_backup/static/description/assets/misc/star.png b/auto_database_backup/static/description/assets/misc/star.png new file mode 100644 index 000000000..2eb9ab29f Binary files /dev/null and b/auto_database_backup/static/description/assets/misc/star.png differ diff --git a/auto_database_backup/static/description/assets/misc/support.png b/auto_database_backup/static/description/assets/misc/support.png new file mode 100644 index 000000000..4f18b8b82 Binary files /dev/null and b/auto_database_backup/static/description/assets/misc/support.png differ diff --git a/auto_database_backup/static/description/assets/misc/whatsapp.png b/auto_database_backup/static/description/assets/misc/whatsapp.png new file mode 100644 index 000000000..d513a5356 Binary files /dev/null and b/auto_database_backup/static/description/assets/misc/whatsapp.png differ diff --git a/auto_database_backup/static/description/assets/modules/1.png b/auto_database_backup/static/description/assets/modules/1.png new file mode 100644 index 000000000..5238bdeab Binary files /dev/null and b/auto_database_backup/static/description/assets/modules/1.png differ diff --git a/auto_database_backup/static/description/assets/modules/2.png b/auto_database_backup/static/description/assets/modules/2.png new file mode 100644 index 000000000..1ae7cfe3b Binary files /dev/null and b/auto_database_backup/static/description/assets/modules/2.png differ diff --git a/auto_database_backup/static/description/assets/modules/3.png b/auto_database_backup/static/description/assets/modules/3.png new file mode 100644 index 000000000..3c3ff1afb Binary files /dev/null and b/auto_database_backup/static/description/assets/modules/3.png differ diff --git a/auto_database_backup/static/description/assets/modules/4.png b/auto_database_backup/static/description/assets/modules/4.png new file mode 100644 index 000000000..3fae4631e Binary files /dev/null and b/auto_database_backup/static/description/assets/modules/4.png differ diff --git a/auto_database_backup/static/description/assets/modules/5.gif b/auto_database_backup/static/description/assets/modules/5.gif new file mode 100644 index 000000000..2a5f8e659 Binary files /dev/null and b/auto_database_backup/static/description/assets/modules/5.gif differ diff --git a/auto_database_backup/static/description/assets/modules/6.png b/auto_database_backup/static/description/assets/modules/6.png new file mode 100644 index 000000000..7f2815273 Binary files /dev/null and b/auto_database_backup/static/description/assets/modules/6.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/backup1.png b/auto_database_backup/static/description/assets/screenshots/backup1.png new file mode 100644 index 000000000..899861ec1 Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/backup1.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/backup10.png b/auto_database_backup/static/description/assets/screenshots/backup10.png new file mode 100644 index 000000000..ddd92a93f Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/backup10.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/backup11.png b/auto_database_backup/static/description/assets/screenshots/backup11.png new file mode 100644 index 000000000..3500f8c70 Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/backup11.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/backup12.png b/auto_database_backup/static/description/assets/screenshots/backup12.png new file mode 100644 index 000000000..99f74c5aa Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/backup12.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/backup13.png b/auto_database_backup/static/description/assets/screenshots/backup13.png new file mode 100644 index 000000000..982d9c83c Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/backup13.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/backup14.png b/auto_database_backup/static/description/assets/screenshots/backup14.png new file mode 100644 index 000000000..756a13c25 Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/backup14.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/backup15.png b/auto_database_backup/static/description/assets/screenshots/backup15.png new file mode 100644 index 000000000..2512c53ce Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/backup15.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/backup16.png b/auto_database_backup/static/description/assets/screenshots/backup16.png new file mode 100644 index 000000000..020345b48 Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/backup16.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/backup17.png b/auto_database_backup/static/description/assets/screenshots/backup17.png new file mode 100644 index 000000000..5e8a6bb8e Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/backup17.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/backup18.png b/auto_database_backup/static/description/assets/screenshots/backup18.png new file mode 100644 index 000000000..05e7392a5 Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/backup18.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/backup2.png b/auto_database_backup/static/description/assets/screenshots/backup2.png new file mode 100644 index 000000000..80afdd5ef Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/backup2.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/backup3.png b/auto_database_backup/static/description/assets/screenshots/backup3.png new file mode 100644 index 000000000..7971483e4 Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/backup3.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/backup4.png b/auto_database_backup/static/description/assets/screenshots/backup4.png new file mode 100644 index 000000000..835112431 Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/backup4.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/backup5.png b/auto_database_backup/static/description/assets/screenshots/backup5.png new file mode 100644 index 000000000..bd6f62d55 Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/backup5.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/backup6.png b/auto_database_backup/static/description/assets/screenshots/backup6.png new file mode 100644 index 000000000..db661d19b Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/backup6.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/backup7.png b/auto_database_backup/static/description/assets/screenshots/backup7.png new file mode 100644 index 000000000..29beb393f Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/backup7.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/backup8.png b/auto_database_backup/static/description/assets/screenshots/backup8.png new file mode 100644 index 000000000..8894a554c Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/backup8.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/backup9.png b/auto_database_backup/static/description/assets/screenshots/backup9.png new file mode 100644 index 000000000..09ff79ec7 Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/backup9.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/drive1.png b/auto_database_backup/static/description/assets/screenshots/drive1.png new file mode 100644 index 000000000..29ea97a8d Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/drive1.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/drive2.png b/auto_database_backup/static/description/assets/screenshots/drive2.png new file mode 100644 index 000000000..725e47372 Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/drive2.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/drive3.png b/auto_database_backup/static/description/assets/screenshots/drive3.png new file mode 100644 index 000000000..efedbc5cf Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/drive3.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/drive4.png b/auto_database_backup/static/description/assets/screenshots/drive4.png new file mode 100644 index 000000000..3b40ae8c5 Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/drive4.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/drive5.png b/auto_database_backup/static/description/assets/screenshots/drive5.png new file mode 100644 index 000000000..da827d867 Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/drive5.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/hero.png b/auto_database_backup/static/description/assets/screenshots/hero.png new file mode 100644 index 000000000..cb468d375 Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/hero.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/onedrive1.png b/auto_database_backup/static/description/assets/screenshots/onedrive1.png new file mode 100644 index 000000000..8d763ea85 Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/onedrive1.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/onedrive2.png b/auto_database_backup/static/description/assets/screenshots/onedrive2.png new file mode 100644 index 000000000..155d97204 Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/onedrive2.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/onedrive3.png b/auto_database_backup/static/description/assets/screenshots/onedrive3.png new file mode 100644 index 000000000..f4e564206 Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/onedrive3.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/onedrive4.png b/auto_database_backup/static/description/assets/screenshots/onedrive4.png new file mode 100644 index 000000000..4ae8a4c0f Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/onedrive4.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/onedrive5.png b/auto_database_backup/static/description/assets/screenshots/onedrive5.png new file mode 100644 index 000000000..44123fcd5 Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/onedrive5.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/onedrive6.png b/auto_database_backup/static/description/assets/screenshots/onedrive6.png new file mode 100644 index 000000000..4f241299c Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/onedrive6.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/onedrive7.png b/auto_database_backup/static/description/assets/screenshots/onedrive7.png new file mode 100644 index 000000000..2da4020c1 Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/onedrive7.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/onedrive8.png b/auto_database_backup/static/description/assets/screenshots/onedrive8.png new file mode 100644 index 000000000..61f5cb9bc Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/onedrive8.png differ diff --git a/auto_database_backup/static/description/assets/screenshots/onedrive9.png b/auto_database_backup/static/description/assets/screenshots/onedrive9.png new file mode 100644 index 000000000..b2894148f Binary files /dev/null and b/auto_database_backup/static/description/assets/screenshots/onedrive9.png differ diff --git a/auto_database_backup/static/description/banner.png b/auto_database_backup/static/description/banner.png new file mode 100644 index 000000000..5ffb4634d Binary files /dev/null and b/auto_database_backup/static/description/banner.png differ diff --git a/auto_database_backup/static/description/icon.png b/auto_database_backup/static/description/icon.png new file mode 100644 index 000000000..cca5cd5bd Binary files /dev/null and b/auto_database_backup/static/description/icon.png differ diff --git a/auto_database_backup/static/description/index.html b/auto_database_backup/static/description/index.html new file mode 100644 index 000000000..06775e43b --- /dev/null +++ b/auto_database_backup/static/description/index.html @@ -0,0 +1,724 @@ +
+ +
+ +
+
+ Community +
+
+ Enterprise +
+ +
+
+ + + + +
+
+
+ +

+ Automatic + Database Backup

+

Automatic Database Backup To + Local + Server, Remote Server, Google Drive, Onedrive And Dropbox.

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

Explore This + Module

+
+ + + + +
+
+ +
+

Overview +

+
+
+
+ This module helps to generate backups of your databases automatically on regular interval of times. + The generated backups can be stored into local storage, ftp server, sftp server, dropbox, Google Drive or + Onedrive. + User can enable auto remove option to automatically delete old backups. + User can enable email notification to be notified about the success and failure of the backup generation + and storage. + Using Automatic Database Backup module user can generate and store database backups to multiple + location. +
+
+ + + +
+
+ +
+

Features +

+
+
+
+
+ + Generate Database + Backups on regular intervals +
+ +
+ + Store Backup to + Dropbox +
+ +
+ + Store Backup to + Onedrive +
+ +
+ + Notify user on success + and failure of backup generation +
+
+
+
+ + Store Backup to Remote + Server +
+ +
+ + Generated backup can be + stored to Google Drive +
+ +
+ + Automatically remove + old backups +
+
+
+ + + +
+
+ +
+

Screenshots +

+
+
+
+ +
+

Database Backup + Configuration Menu

+

+ Got Setting --> Technical --> Backup Configuration to configure backups

+ +
+ +
+

Crate New Database Backup + Configuration

+

+ Enter the database name and master password. specify backup type and destination. + Enter the backup directory path, if directory does not exist new directory will be created.

+ +
+ +
+

Store Backup to Remote + SFTP Server

+

+ Select backup destination as SFTP, enter credentials. + Test connection button to check whether the connection is successful. +

+ +
+ +
+

Store Backup to Remote + FTP Server

+

Select backup destination + as FTP, enter credentials. + Test connection button to check whether the connection is successful.

+ +
+ +
+

Store Backup to Google + Drive

+

you'll need to create a new + Google API project and enabling the Google Drive API, Go to the Google API Console and log into your + account. + While creating the project, for the Redirect URI restrictions, copy your Odoo database URI followed by + /google_drive/authentication. Example:

+ +

Enable Google Drive API

+ + +

Create Credentials, Follow + the steps, select Website application for the Application Type.

+ +

Under the Authorized + JavaScript Origins section, click + Add URI and type your company’s Odoo URL address. + Under the Authorized redirect URIs section, click + Add URI and type your company’s Odoo URL address followed + by /google_drive/authentication. + After all the steps are completed, A client ID and Secret will be given, copy the credentials +

+ +

Configure Backup, Copy + Client ID and Client Secret from Google Drive API Credentials page into their respective fields.

+ +

Setup Tokens, it will be + redirected to an authorization page.

+ + +

Reset the token if + required.

+ +
+ + +
+

Store Backup to Dropbox +

+

Select backup destination + as Dropbox. Enter the App key and App secret. + you'll need to register a new app in the App + Console. + Select Dropbox API app and choose your app's permission (files.content.write and files.content.read + permissions + required). +

+

Install python dropbox + library (pip install dropbox).

+ +

Setup refresh token

+ +

Get the authorization code + and click confirm.

+ +

Reset the refresh token if + required

+ +
+ +
+

Store Backup to Onedrive +

+

Select backup destination + as onedrive. Enter the App key and App secret. + you'll need to register a new app in the Microsoft Azure + portal. + While registering the app for the Redirect URI restrictions, copy your Odoo database URI followed by + /onedrive/authentication. Example:

+ +

Copy the Client ID

+ +

Generate Client Secret.

+ + +

get onedrive folder ID, + where need to store the backup files.

+ +

Configure the backup

+ +

Setup Tokens, it will be + redirected to an authorization page.

+ + +

Reset the token if required +

+ +
+ +
+

Automatically Remove Old + Backups

+

TEnable auto remove option, + specify number of days to remove backups.

+ +
+ +
+

Notify User on Success + and Failure of Backup Generation

+

Enable notify user option, + and select a user to notify. An email notification will be sent to the selected user on + backup successful and failure. +

+ +
+ +
+

Successful backup + notification email

+ +
+ +
+

Notification email when + backup generation failed

+ +
+ +
+

Scheduled Action For + Generating Backup

+

Enable the 'Automatic + database Backup' scheduled action, and set up the execution interval. + Based on the scheduled action setup, backups will be generated on regular intervals.

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

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/auto_database_backup/views/db_backup_configure_views.xml b/auto_database_backup/views/db_backup_configure_views.xml new file mode 100644 index 000000000..0d91a9592 --- /dev/null +++ b/auto_database_backup/views/db_backup_configure_views.xml @@ -0,0 +1,212 @@ + + + + + + + + db.backup.configure.list + db.backup.configure + + + + + + + + + + + + db.backup.configure.form + db.backup.configure + +
+ +
+

+ +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + Refresh token set +
+
+ + No refresh token set +
+
+
+
+ +
+
+ +
+
+
+
+ + Refresh token set +
+
+ + No refresh token set +
+
+
+
+ +
+
+ +
+
+
+
+ + Refresh token set +
+
+ + No refresh token set +
+
+
+
+ +
+
+ +
+
+
+ + + + + + + + + +