Browse Source

[IMP] Dropbox feature updated 'auto_database_backup'

pull/207/head
AjmalCybro 3 years ago
parent
commit
ebf8cd9ef2
  1. 4
      auto_database_backup/README.rst
  2. 3
      auto_database_backup/__init__.py
  3. 11
      auto_database_backup/__manifest__.py
  4. 19
      auto_database_backup/data/data.xml
  5. 5
      auto_database_backup/doc/RELEASE_NOTES.md
  6. 2
      auto_database_backup/models/__init__.py
  7. 87
      auto_database_backup/models/db_backup_configure.py
  8. 1
      auto_database_backup/security/ir.model.access.csv
  9. BIN
      auto_database_backup/static/description/assets/icons/f-alarm.png
  10. BIN
      auto_database_backup/static/description/assets/icons/f-backup.png
  11. BIN
      auto_database_backup/static/description/assets/icons/f-dropbox.png
  12. BIN
      auto_database_backup/static/description/assets/icons/f-ftp.png
  13. BIN
      auto_database_backup/static/description/assets/icons/f-google-drive.png
  14. BIN
      auto_database_backup/static/description/assets/icons/f-remove-database.png
  15. BIN
      auto_database_backup/static/description/assets/icons/f-sftp.png
  16. BIN
      auto_database_backup/static/description/banner.gif
  17. 185
      auto_database_backup/static/description/index.html
  18. 33
      auto_database_backup/views/db_backup_configure_views.xml
  19. 23
      auto_database_backup/wizard/__init__.py
  20. 42
      auto_database_backup/wizard/dropbox_auth_code_wizard.py
  21. 27
      auto_database_backup/wizard/dropbox_authcode_wizard_views.xml

4
auto_database_backup/README.rst

@ -1,5 +1,5 @@
Automatic Database Backup Automatic Database Backup To Local Server, Remote Server, Google Drive And Dropbox
========================= ==================================================================================
* Generate Database Backups and store to multiple locations * Generate Database Backups and store to multiple locations
Installation Installation

3
auto_database_backup/__init__.py

@ -3,7 +3,7 @@
# #
# Cybrosys Technologies Pvt. Ltd. # Cybrosys Technologies Pvt. Ltd.
# #
# Copyright (C) 2021-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) # Copyright (C) 2022-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) # Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
# #
# You can modify it under the terms of the GNU LESSER # You can modify it under the terms of the GNU LESSER
@ -19,3 +19,4 @@
# If not, see <http://www.gnu.org/licenses/>. # If not, see <http://www.gnu.org/licenses/>.
from . import models from . import models
from . import wizard

11
auto_database_backup/__manifest__.py

@ -3,7 +3,7 @@
# #
# Cybrosys Technologies Pvt. Ltd. # Cybrosys Technologies Pvt. Ltd.
# #
# Copyright (C) 2021-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) # Copyright (C) 2022-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) # Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
# #
# You can modify it under the terms of the GNU LESSER # You can modify it under the terms of the GNU LESSER
@ -21,9 +21,9 @@
############################################################################# #############################################################################
{ {
'name': "Automatic Database Backup", 'name': "Automatic Database Backup To Local Server, Remote Server, Google Drive And Dropbox",
'version': '15.0.1.0.0', 'version': '15.0.2.0.1',
'summary': """Generate automatic backup of databases and store to local, google drive or remote server""", 'summary': """Generate automatic backup of databases and store to local, google drive, dropbox or remote server""",
'description': """This module has been developed for creating database backups automatically 'description': """This module has been developed for creating database backups automatically
and store it to the different locations.""", and store it to the different locations.""",
'author': "Cybrosys Techno Solutions", 'author': "Cybrosys Techno Solutions",
@ -35,7 +35,8 @@
'data': [ 'data': [
'security/ir.model.access.csv', 'security/ir.model.access.csv',
'data/data.xml', 'data/data.xml',
'views/db_backup_configure_views.xml' 'views/db_backup_configure_views.xml',
'wizard/dropbox_authcode_wizard_views.xml'
], ],
'license': 'LGPL-3', 'license': 'LGPL-3',
'images': ['static/description/banner.gif'], 'images': ['static/description/banner.gif'],

19
auto_database_backup/data/data.xml

@ -48,6 +48,9 @@
<t t-elif="object.backup_destination == 'sftp'"> <t t-elif="object.backup_destination == 'sftp'">
<i>SFTP Server</i> <i>SFTP Server</i>
</t> </t>
<t t-elif="object.backup_destination == 'dropbox'">
<i>Dropbox</i>
</t>
. .
<br/> <br/>
<br/> <br/>
@ -67,7 +70,10 @@
<t t-elif="object.backup_destination == 'sftp'"> <t t-elif="object.backup_destination == 'sftp'">
SFTP Server SFTP Server
</t> </t>
<t t-if="object.backup_destination in ('local', 'ftp', 'sftp')"> <t t-elif="object.backup_destination == 'dropbox'">
Dropbox
</t>
<t t-if="object.backup_destination in ('local', 'ftp', 'sftp', 'dropbox')">
<br/> <br/>
Backup Path: Backup Path:
<t t-if="object.backup_destination == 'local'"> <t t-if="object.backup_destination == 'local'">
@ -79,6 +85,9 @@
<t t-elif="object.backup_destination == 'sftp'"> <t t-elif="object.backup_destination == 'sftp'">
<t t-out="object.sftp_path"/> <t t-out="object.sftp_path"/>
</t> </t>
<t t-elif="object.backup_destination == 'dropbox'">
<t t-out="object.dropbox_folder"/>
</t>
</t> </t>
<br/> <br/>
Backup Type: Backup Type:
@ -127,7 +136,10 @@
<t t-elif="object.backup_destination == 'sftp'"> <t t-elif="object.backup_destination == 'sftp'">
SFTP Server SFTP Server
</t> </t>
<t t-if="object.backup_destination in ('local', 'ftp', 'sftp')"> <t t-elif="object.backup_destination == 'dropbox'">
Dropbox
</t>
<t t-if="object.backup_destination in ('local', 'ftp', 'sftp', 'dropbox')">
<br/> <br/>
Backup Path: Backup Path:
<t t-if="object.backup_destination == 'local'"> <t t-if="object.backup_destination == 'local'">
@ -139,6 +151,9 @@
<t t-elif="object.backup_destination == 'sftp'"> <t t-elif="object.backup_destination == 'sftp'">
<t t-out="object.sftp_path"/> <t t-out="object.sftp_path"/>
</t> </t>
<t t-elif="object.backup_destination == 'dropbox'">
<t t-out="object.dropbox_folder"/>
</t>
</t> </t>
<br/> <br/>
Backup Type: <t t-out="object.backup_format"/> Backup Type: <t t-out="object.backup_format"/>

5
auto_database_backup/doc/RELEASE_NOTES.md

@ -5,5 +5,8 @@
#### ADD #### ADD
- Initial commit for auto_database_backup - Initial commit for auto_database_backup
#### 14.06.2022
#### Version 15.0.1.0.1
#### ADD
- Dropbox integration added. Backup can be stored in to dropbox.

2
auto_database_backup/models/__init__.py

@ -3,7 +3,7 @@
# #
# Cybrosys Technologies Pvt. Ltd. # Cybrosys Technologies Pvt. Ltd.
# #
# Copyright (C) 2021-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) # Copyright (C) 2022-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) # Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
# #
# You can modify it under the terms of the GNU LESSER # You can modify it under the terms of the GNU LESSER

87
auto_database_backup/models/db_backup_configure.py

@ -3,7 +3,7 @@
# #
# Cybrosys Technologies Pvt. Ltd. # Cybrosys Technologies Pvt. Ltd.
# #
# Copyright (C) 2021-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) # Copyright (C) 2022-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>) # Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
# #
# You can modify it under the terms of the GNU LESSER # You can modify it under the terms of the GNU LESSER
@ -25,6 +25,8 @@ from odoo.exceptions import UserError, ValidationError
import odoo import odoo
from odoo.service import db from odoo.service import db
import dropbox
import datetime import datetime
import os import os
import paramiko import paramiko
@ -53,21 +55,26 @@ class AutoDatabaseBackup(models.Model):
('local', 'Local Storage'), ('local', 'Local Storage'),
('google_drive', 'Google Drive'), ('google_drive', 'Google Drive'),
('ftp', 'FTP'), ('ftp', 'FTP'),
('sftp', 'SFTP') ('sftp', 'SFTP'),
('dropbox', 'Dropbox')
], string='Backup Destination') ], string='Backup Destination')
backup_path = fields.Char(string='Backup Path', help='Local storage directory path') backup_path = fields.Char(string='Backup Path', help='Local storage directory path')
sftp_host = fields.Char(string='SFTP Host') sftp_host = fields.Char(string='SFTP Host')
sftp_port = fields.Char(string='SFTP Port', default=22) sftp_port = fields.Char(string='SFTP Port', default=22)
sftp_user = fields.Char(string='SFTP User') sftp_user = fields.Char(string='SFTP User', copy=False)
sftp_password = fields.Char(string='SFTP Password') sftp_password = fields.Char(string='SFTP Password', copy=False)
sftp_path = fields.Char(string='SFTP Path') sftp_path = fields.Char(string='SFTP Path')
ftp_host = fields.Char(string='FTP Host') ftp_host = fields.Char(string='FTP Host')
ftp_port = fields.Char(string='FTP Port', default=21) ftp_port = fields.Char(string='FTP Port', default=21)
ftp_user = fields.Char(string='FTP User') ftp_user = fields.Char(string='FTP User', copy=False)
ftp_password = fields.Char(string='FTP Password') ftp_password = fields.Char(string='FTP Password', copy=False)
ftp_path = fields.Char(string='FTP Path') 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) active = fields.Boolean(default=True)
save_to_drive = fields.Boolean()
auto_remove = fields.Boolean(string='Remove Old Backups') auto_remove = fields.Boolean(string='Remove Old Backups')
days_to_remove = fields.Integer(string='Remove After', days_to_remove = fields.Integer(string='Remove After',
help='Automatically delete stored backups after this specified number of days') help='Automatically delete stored backups after this specified number of days')
@ -78,10 +85,48 @@ class AutoDatabaseBackup(models.Model):
backup_filename = fields.Char(string='Backup Filename', help='For Storing generated backup filename') 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') generated_exception = fields.Char(string='Exception', help='Exception Encountered while Backup generation')
@api.constrains('db_name', 'master_pwd') @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)
def action_get_dropbox_auth_code(self):
"""
Open a wizard to setup dropbox Authorization code
"""
return {
'type': 'ir.actions.act_window',
'name': 'Dropbox Authorization Wizard',
'res_model': 'dropbox.auth.wizard',
'view_mode': 'form',
'target': 'new',
}
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): def _check_db_credentials(self):
""" """
Validate enetered database name and master password Validate entered database name and master password
""" """
database_list = db.list_dbs() database_list = db.list_dbs()
if self.db_name not in database_list: if self.db_name not in database_list:
@ -133,7 +178,6 @@ class AutoDatabaseBackup(models.Model):
""" """
records = self.search([]) records = self.search([])
mail_template_success = self.env.ref('auto_database_backup.mail_template_data_db_backup_successful') mail_template_success = self.env.ref('auto_database_backup.mail_template_data_db_backup_successful')
print('mail template success', mail_template_success)
mail_template_failed = self.env.ref('auto_database_backup.mail_template_data_db_backup_failed') mail_template_failed = self.env.ref('auto_database_backup.mail_template_data_db_backup_failed')
for rec in records: for rec in records:
backup_time = datetime.datetime.utcnow().strftime("%Y-%m-%d_%H-%M-%S") backup_time = datetime.datetime.utcnow().strftime("%Y-%m-%d_%H-%M-%S")
@ -157,7 +201,6 @@ class AutoDatabaseBackup(models.Model):
if backup_duration.days >= rec.days_to_remove: if backup_duration.days >= rec.days_to_remove:
os.remove(file) os.remove(file)
if rec.notify_user: if rec.notify_user:
print('success notify')
mail_template_success.send_mail(rec.id, force_send=True) mail_template_success.send_mail(rec.id, force_send=True)
except Exception as e: except Exception as e:
rec.generated_exception = e rec.generated_exception = e
@ -265,3 +308,25 @@ class AutoDatabaseBackup(models.Model):
_logger.info('Google Drive Exception: %s', e) _logger.info('Google Drive Exception: %s', e)
if rec.notify_user: if rec.notify_user:
mail_template_failed.send_mail(rec.id, force_send=True) 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)

1
auto_database_backup/security/ir.model.access.csv

@ -1,2 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink 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_db_backup_configure,access.db.backup.configure,model_db_backup_configure,base.group_user,1,1,1,1
access_dropbox_auth_wizard,access.dropbox.auth.wizard,model_dropbox_auth_wizard,base.group_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_db_backup_configure access.db.backup.configure model_db_backup_configure base.group_user 1 1 1 1
3 access_dropbox_auth_wizard access.dropbox.auth.wizard model_dropbox_auth_wizard base.group_user 1 1 1 1

BIN
auto_database_backup/static/description/assets/icons/f-alarm.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

BIN
auto_database_backup/static/description/assets/icons/f-backup.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

BIN
auto_database_backup/static/description/assets/icons/f-dropbox.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
auto_database_backup/static/description/assets/icons/f-ftp.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
auto_database_backup/static/description/assets/icons/f-google-drive.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

BIN
auto_database_backup/static/description/assets/icons/f-remove-database.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
auto_database_backup/static/description/assets/icons/f-sftp.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
auto_database_backup/static/description/banner.gif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 330 KiB

After

Width:  |  Height:  |  Size: 437 KiB

185
auto_database_backup/static/description/index.html

@ -7,7 +7,8 @@
Automatic Database Backup</h1> Automatic Database Backup</h1>
<p <p
style="font-family: 'Montserrat', sans-serif !important; font-weight: 300 !important; color: #FFFFFF !important; font-size: 1.4rem !important; text-align: center !important;"> style="font-family: 'Montserrat', sans-serif !important; font-weight: 300 !important; color: #FFFFFF !important; font-size: 1.4rem !important; text-align: center !important;">
Generate Automatic Back up of databases and store to local, google drive or remote server Generate Automatic Back up of databases and store to Local Storage, Google Drive, Dropbox And Remote
Server
</p> </p>
<img src="./assets/screenshots/hero.png" class="img-responsive" width="100%" height="auto"/> <img src="./assets/screenshots/hero.png" class="img-responsive" width="100%" height="auto"/>
</div> </div>
@ -110,89 +111,121 @@
</div> </div>
<div class="col-md-6 pl-3 py-3 d-flex"> <div class="col-md-6 pl-3 py-3 d-flex">
<div> <div class="container shadow"
<img src="assets/icons/check.png"> style="border-radius:10px; padding:10px 0px; display: flex; align-items: center;">
<div class="col-md-3" style="display: flex; justify-content: center; align-items: center;">
<img class="img img-responsive" width="60" height="60" src="/assets/icons/f-backup.png">
</div>
<div class="col-md-9" style="padding-left:0; float:left; width:70%;">
<h3 class="mt16 mb0" style="font-family:Roboto; font-weight:500; font-size:22px">
Generate Database Backup</h3>
<p class="mt8" style="font-family:Roboto; margin-bottom: 0 !important;">
Generate database backups on regular intervals
</p>
</div> </div>
<div>
<h4
style="font-family: 'Roboto', sans-serif !important; font-weight: 600 !important; color: #282F33 !important; font-size: 1.3rem !important;">
Generate Database Backup</h4>
<p
style="font-family: 'Roboto', sans-serif !important; font-weight: 400 !important; color: #282F33 !important; font-size: 1rem !important;">
Generate database backups on regular intervals.</p>
</div> </div>
</div> </div>
<div class="col-md-6 pl-3 py-3 d-flex"> <div class="col-md-6 pl-3 py-3 d-flex">
<div> <div class="container shadow"
<img src="assets/icons/check.png"> style="border-radius:10px; padding:10px 0px; display: flex; align-items: center;">
<div class="col-md-3" style="display: flex; justify-content: center; align-items: center;">
<img class="img img-responsive" width="60" height="60" src="/assets/icons/f-ftp.png">
</div>
<div class="col-md-9" style="padding-left:0; float:left; width:70%;">
<h3 class="mt16 mb0" style="font-family:Roboto; font-weight:500; font-size:22px">
Store Backup to FTP Server</h3>
<p class="mt8" style="font-family:Roboto; margin-bottom: 0 !important;">
Generated backup can be stored to remote FTP server.
</p>
</div> </div>
<div>
<h4
style="font-family: 'Roboto', sans-serif !important; font-weight: 600 !important; color: #282F33 !important; font-size: 1.3rem !important;">
Store Backup to FTP Server</h4>
<p
style="font-family: 'Roboto', sans-serif !important; font-weight: 400 !important; color: #282F33 !important; font-size: 1rem !important;">
Generated backup can be stored to remote FTP server.</p>
</div> </div>
</div> </div>
<div class="col-md-6 pl-3 py-3 d-flex"> <div class="col-md-6 pl-3 py-3 d-flex">
<div> <div class="container shadow"
<img src="assets/icons/check.png"> style="border-radius:10px; padding:10px 0px; display: flex; align-items: center;">
<div class="col-md-3" style="display: flex; justify-content: center; align-items: center;">
<img class="img img-responsive" width="60" height="60" src="/assets/icons/f-sftp.png">
</div>
<div class="col-md-9" style="padding-left:0; float:left; width:70%;">
<h3 class="mt16 mb0" style="font-family:Roboto; font-weight:500; font-size:22px">
Store Backup to SFTP Server</h3>
<p class="mt8" style="font-family:Roboto; margin-bottom: 0 !important;">
Generated backup can be stored to remote SFTP server.
</p>
</div> </div>
<div>
<h4
style="font-family: 'Roboto', sans-serif !important; font-weight: 600 !important; color: #282F33 !important; font-size: 1.3rem !important;">
Store Backup to SFTP Server</h4>
<p
style="font-family: 'Roboto', sans-serif !important; font-weight: 400 !important; color: #282F33 !important; font-size: 1rem !important;">
Generated backup can be stored to remote SFTP server.</p>
</div> </div>
</div> </div>
<div class="col-md-6 pl-3 py-3 d-flex"> <div class="col-md-6 pl-3 py-3 d-flex">
<div> <div class="container shadow"
<img src="assets/icons/check.png"> style="border-radius:10px; padding:10px 0px; display: flex; align-items: center;">
<div class="col-md-3" style="display: flex; justify-content: center; align-items: center;">
<img class="img img-responsive" width="60" height="60" src="/assets/icons/f-google-drive.png">
</div>
<div class="col-md-9" style="padding-left:0; float:left; width:70%;">
<h3 class="mt16 mb0" style="font-family:Roboto; font-weight:500; font-size:22px">
Store Backup to Google Drive</h3>
<p class="mt8" style="font-family:Roboto; margin-bottom: 0 !important;">
Generated backup can be stored to Google Drive.
</p>
</div> </div>
<div>
<h4
style="font-family: 'Roboto', sans-serif !important; font-weight: 600 !important; color: #282F33 !important; font-size: 1.3rem !important;">
Store Backup to Google drive</h4>
<p
style="font-family: 'Roboto', sans-serif !important; font-weight: 400 !important; color: #282F33 !important; font-size: 1rem !important;">
Generated backup can be stored to google drive.</p>
</div> </div>
</div> </div>
<div class="col-md-6 pl-3 py-3 d-flex"> <div class="col-md-6 pl-3 py-3 d-flex">
<div> <div class="container shadow"
<img src="assets/icons/check.png"> style="border-radius:10px; padding:10px 0px; display: flex; align-items: center;">
<div class="col-md-3" style="display: flex; justify-content: center; align-items: center;">
<img class="img img-responsive" width="60" height="60" src="/assets/icons/f-dropbox.png">
</div>
<div class="col-md-9" style="padding-left:0; float:left; width:70%;">
<h3 class="mt16 mb0" style="font-family:Roboto; font-weight:500; font-size:22px">
Store Backup to Dropbox</h3>
<p class="mt8" style="font-family:Roboto; margin-bottom: 0 !important;">
Generated backup can be stored to Dropbox.
</p>
</div> </div>
<div>
<h4
style="font-family: 'Roboto', sans-serif !important; font-weight: 600 !important; color: #282F33 !important; font-size: 1.3rem !important;">
Automatically remove old backups.</h4>
<p
style="font-family: 'Roboto', sans-serif !important; font-weight: 400 !important; color: #282F33 !important; font-size: 1rem !important;">
Old backups files will be deleted automatically based on the obsolescence of backup.</p>
</div> </div>
</div> </div>
<div class="col-md-6 pl-3 py-3 d-flex"> <div class="col-md-6 pl-3 py-3 d-flex">
<div> <div class="container shadow"
<img src="assets/icons/check.png"> style="border-radius:10px; padding:10px 0px; display: flex; align-items: center;">
<div class="col-md-3" style="display: flex; justify-content: center; align-items: center;">
<img class="img img-responsive" width="60" height="60" src="/assets/icons/f-remove-database.png">
</div>
<div class="col-md-9" style="padding-left:0; float:left; width:70%;">
<h3 class="mt16 mb0" style="font-family:Roboto; font-weight:500; font-size:22px">
Automatically remove old backups</h3>
<p class="mt8" style="font-family:Roboto; margin-bottom: 0 !important;">
Old backups files will be deleted automatically based on the obsolescence of backup.
</p>
</div> </div>
<div>
<h4
style="font-family: 'Roboto', sans-serif !important; font-weight: 600 !important; color: #282F33 !important; font-size: 1.3rem !important;">
Notify user on success and failure of backup generation</h4>
<p
style="font-family: 'Roboto', sans-serif !important; font-weight: 400 !important; color: #282F33 !important; font-size: 1rem !important;">
An email notification send to user on successful backup generation also send an email notification when backup operation failed.</p>
</div> </div>
</div> </div>
<div class="col-md-6 pl-3 py-3 d-flex">
<div class="container shadow"
style="border-radius:10px; padding:10px 0px; display: flex; align-items: center;">
<div class="col-md-3" style="display: flex; justify-content: center; align-items: center;">
<img class="img img-responsive" width="60" height="60" src="/assets/icons/f-alarm.png">
</div>
<div class="col-md-9" style="padding-left:0; float:left; width:70%;">
<h3 class="mt16 mb0" style="font-family:Roboto; font-weight:500; font-size:22px">
Notify user on success and failure of backup generation</h3>
<p class="mt8" style="font-family:Roboto; margin-bottom: 0 !important;">
An email notification send to user on successful backup generation also send an email
notification when
backup operation failed.
</p>
</div>
</div>
</div>
</div> </div>
<div class="row" id="screenshots"> <div class="row" id="screenshots">
@ -422,9 +455,10 @@
</div> </div>
<!-- Left and right controls --> <!-- Left and right controls -->
<a class="carousel-control-prev" href="#demo1" data-slide="prev" <a class="carousel-control-prev" href="#demo1" data-slide="prev"
style="left:-25px;width: 35px;color: #000;"> <span class="carousel-control-prev-icon"><i style="left:-25px;width: 35px;color: #000;">
class="fa fa-chevron-left" style="font-size:24px"></i></span> </a> <a <span class="carousel-control-prev-icon"><i class="fa fa-chevron-left"
class="carousel-control-next" href="#demo1" data-slide="next" style="font-size:24px"></i></span>
</a> <a class="carousel-control-next" href="#demo1" data-slide="next"
style="right:-25px;width: 35px;color: #000;"> style="right:-25px;width: 35px;color: #000;">
<span class="carousel-control-next-icon"><i class="fa fa-chevron-right" <span class="carousel-control-next-icon"><i class="fa fa-chevron-right"
style="font-size:24px"></i></span> style="font-size:24px"></i></span>
@ -552,8 +586,7 @@
<div class="my-4 d-flex flex-column justify-content-center" <div class="my-4 d-flex flex-column justify-content-center"
style="background-color: #f6f8f9 !important; border-radius: 10px; padding: 2rem !important; height: 250px !important;"> style="background-color: #f6f8f9 !important; border-radius: 10px; padding: 2rem !important; height: 250px !important;">
<img src="./assets/icons/trading-black.png" class="img-responsive mb-3" height="48px" width="48px"> <img src="./assets/icons/trading-black.png" class="img-responsive mb-3" height="48px" width="48px">
<h5 <h5 style="font-family: Montserrat, sans-serif !important; color: #000 !important; font-weight: bold;">
style="font-family: Montserrat, sans-serif !important; color: #000 !important; font-weight: bold;">
Trading Trading
</h5> </h5>
<p style="font-family: Montserrat, sans-serif !important; font-size: 0.9rem !important;"> <p style="font-family: Montserrat, sans-serif !important; font-size: 0.9rem !important;">
@ -567,8 +600,7 @@
<div class="my-4 d-flex flex-column justify-content-center" <div class="my-4 d-flex flex-column justify-content-center"
style="background-color: #f6f8f9 !important; border-radius: 10px; padding: 2rem !important; height: 250px !important;"> style="background-color: #f6f8f9 !important; border-radius: 10px; padding: 2rem !important; height: 250px !important;">
<img src="./assets/icons/pos-black.png" class="img-responsive mb-3" height="48px" width="48px"> <img src="./assets/icons/pos-black.png" class="img-responsive mb-3" height="48px" width="48px">
<h5 <h5 style="font-family: Montserrat, sans-serif !important; color: #000 !important; font-weight: bold;">
style="font-family: Montserrat, sans-serif !important; color: #000 !important; font-weight: bold;">
POS POS
</h5> </h5>
<p style="font-family: Montserrat, sans-serif !important; font-size: 0.9rem !important;"> <p style="font-family: Montserrat, sans-serif !important; font-size: 0.9rem !important;">
@ -583,8 +615,7 @@
style="background-color: #f6f8f9 !important; border-radius: 10px; padding: 2rem !important; height: 250px !important;"> style="background-color: #f6f8f9 !important; border-radius: 10px; padding: 2rem !important; height: 250px !important;">
<img src="./assets/icons/education-black.png" class="img-responsive mb-3" height="48px" <img src="./assets/icons/education-black.png" class="img-responsive mb-3" height="48px"
width="48px"> width="48px">
<h5 <h5 style="font-family: Montserrat, sans-serif !important; color: #000 !important; font-weight: bold;">
style="font-family: Montserrat, sans-serif !important; color: #000 !important; font-weight: bold;">
Education Education
</h5> </h5>
<p style="font-family: Montserrat, sans-serif !important; font-size: 0.9rem !important;"> <p style="font-family: Montserrat, sans-serif !important; font-size: 0.9rem !important;">
@ -598,8 +629,7 @@
style="background-color: #f6f8f9 !important; border-radius: 10px; padding: 2rem !important; height: 250px !important;"> style="background-color: #f6f8f9 !important; border-radius: 10px; padding: 2rem !important; height: 250px !important;">
<img src="./assets/icons/manufacturing-black.png" class="img-responsive mb-3" height="48px" <img src="./assets/icons/manufacturing-black.png" class="img-responsive mb-3" height="48px"
width="48px"> width="48px">
<h5 <h5 style="font-family: Montserrat, sans-serif !important; color: #000 !important; font-weight: bold;">
style="font-family: Montserrat, sans-serif !important; color: #000 !important; font-weight: bold;">
Manufacturing Manufacturing
</h5> </h5>
<p style="font-family: Montserrat, sans-serif !important; font-size: 0.9rem !important;"> <p style="font-family: Montserrat, sans-serif !important; font-size: 0.9rem !important;">
@ -612,8 +642,7 @@
<div class="my-4 d-flex flex-column justify-content-center" <div class="my-4 d-flex flex-column justify-content-center"
style="background-color: #f6f8f9 !important; border-radius: 10px; padding: 2rem !important; height: 250px !important;"> style="background-color: #f6f8f9 !important; border-radius: 10px; padding: 2rem !important; height: 250px !important;">
<img src="./assets/icons/ecom-black.png" class="img-responsive mb-3" height="48px" width="48px"> <img src="./assets/icons/ecom-black.png" class="img-responsive mb-3" height="48px" width="48px">
<h5 <h5 style="font-family: Montserrat, sans-serif !important; color: #000 !important; font-weight: bold;">
style="font-family: Montserrat, sans-serif !important; color: #000 !important; font-weight: bold;">
E-commerce &amp; Website E-commerce &amp; Website
</h5> </h5>
<p style="font-family: Montserrat, sans-serif !important; font-size: 0.9rem !important;"> <p style="font-family: Montserrat, sans-serif !important; font-size: 0.9rem !important;">
@ -627,8 +656,7 @@
<div class="my-4 d-flex flex-column justify-content-center" <div class="my-4 d-flex flex-column justify-content-center"
style="background-color: #f6f8f9 !important; border-radius: 10px; padding: 2rem !important; height: 250px !important;"> style="background-color: #f6f8f9 !important; border-radius: 10px; padding: 2rem !important; height: 250px !important;">
<img src="./assets/icons/service-black.png" class="img-responsive mb-3" height="48px" width="48px"> <img src="./assets/icons/service-black.png" class="img-responsive mb-3" height="48px" width="48px">
<h5 <h5 style="font-family: Montserrat, sans-serif !important; color: #000 !important; font-weight: bold;">
style="font-family: Montserrat, sans-serif !important; color: #000 !important; font-weight: bold;">
Service Management Service Management
</h5> </h5>
<p style="font-family: Montserrat, sans-serif !important; font-size: 0.9rem !important;"> <p style="font-family: Montserrat, sans-serif !important; font-size: 0.9rem !important;">
@ -642,8 +670,7 @@
style="background-color: #f6f8f9 !important; border-radius: 10px; padding: 2rem !important; height: 250px !important;"> style="background-color: #f6f8f9 !important; border-radius: 10px; padding: 2rem !important; height: 250px !important;">
<img src="./assets/icons/restaurant-black.png" class="img-responsive mb-3" height="48px" <img src="./assets/icons/restaurant-black.png" class="img-responsive mb-3" height="48px"
width="48px"> width="48px">
<h5 <h5 style="font-family: Montserrat, sans-serif !important; color: #000 !important; font-weight: bold;">
style="font-family: Montserrat, sans-serif !important; color: #000 !important; font-weight: bold;">
Restaurant Restaurant
</h5> </h5>
<p style="font-family: Montserrat, sans-serif !important; font-size: 0.9rem !important;"> <p style="font-family: Montserrat, sans-serif !important; font-size: 0.9rem !important;">
@ -656,8 +683,7 @@
<div class="my-4 d-flex flex-column justify-content-center" <div class="my-4 d-flex flex-column justify-content-center"
style="background-color: #f6f8f9 !important; border-radius: 10px; padding: 2rem !important; height: 250px !important;"> style="background-color: #f6f8f9 !important; border-radius: 10px; padding: 2rem !important; height: 250px !important;">
<img src="./assets/icons/hotel-black.png" class="img-responsive mb-3" height="48px" width="48px"> <img src="./assets/icons/hotel-black.png" class="img-responsive mb-3" height="48px" width="48px">
<h5 <h5 style="font-family: Montserrat, sans-serif !important; color: #000 !important; font-weight: bold;">
style="font-family: Montserrat, sans-serif !important; color: #000 !important; font-weight: bold;">
Hotel Management Hotel Management
</h5> </h5>
<p style="font-family: Montserrat, sans-serif !important; font-size: 0.9rem !important;"> <p style="font-family: Montserrat, sans-serif !important; font-size: 0.9rem !important;">
@ -690,21 +716,16 @@
<div class="col-lg-12" style="padding: 0rem 3rem 2rem; border-radius: 10px; margin-right: 3rem; "> <div class="col-lg-12" style="padding: 0rem 3rem 2rem; border-radius: 10px; margin-right: 3rem; ">
<div class="row mt-4"> <div class="row mt-4">
<div class="col-lg-4"> <div class="col-lg-6">
<a href="mailto:odoo@cybrosys.com" target="_blank" class="btn btn-block mb-2 deep_hover" <a href="mailto:odoo@cybrosys.com" target="_blank" class="btn btn-block mb-2 deep_hover"
style="text-decoration: none; background-color: #4d4d4d; color: #FFF; border-radius: 4px;"><i style="text-decoration: none; background-color: #4d4d4d; color: #FFF; border-radius: 4px;"><i
class="fa fa-envelope mr-2"></i>odoo@cybrosys.com</a> class="fa fa-envelope mr-2"></i>odoo@cybrosys.com</a>
</div> </div>
<div class="col-lg-4"> <div class="col-lg-6">
<a href="https://api.WhatsApp.com/send?phone=918606827707" target="_blank" <a href="https://api.WhatsApp.com/send?phone=918606827707" target="_blank"
class="btn btn-block mb-2 deep_hover" class="btn btn-block mb-2 deep_hover"
style="text-decoration: none; background-color: #25D366; color: #FFF; border-radius: 4px;"><i style="text-decoration: none; background-color: #25D366; color: #FFF; border-radius: 4px;"><i
class="fa fa-WhatsApp mr-2"></i>WhatsApp</a> class="fa fa-whatsapp mr-2"></i>+91 8606827707</a>
</div>
<div class="col-lg-4">
<a href="mailto:info@cybrosys.com" target="_blank" class="btn btn-block deep_hover"
style="text-decoration: none; background-color: #4d4d4d; color: #FFF; border-radius: 4px;"><i
class="fa fa-envelope mr-2"></i>info@cybrosys.com</a>
</div> </div>
</div> </div>
</div> </div>

33
auto_database_backup/views/db_backup_configure_views.xml

@ -50,6 +50,39 @@
<field name="sftp_password" attrs="{'invisible': [('backup_destination', '!=', 'sftp')], 'required': [('backup_destination', '=', 'sftp')]}" password="True"/> <field name="sftp_password" attrs="{'invisible': [('backup_destination', '!=', 'sftp')], 'required': [('backup_destination', '=', 'sftp')]}" password="True"/>
<field name="sftp_path" attrs="{'invisible': [('backup_destination', '!=', 'sftp')], 'required': [('backup_destination', '=', 'sftp')]}"/> <field name="sftp_path" attrs="{'invisible': [('backup_destination', '!=', 'sftp')], 'required': [('backup_destination', '=', 'sftp')]}"/>
<field name="google_drive_folderid" attrs="{'invisible': [('backup_destination', '!=', 'google_drive')], 'required': [('backup_destination', '=', 'google_drive')]}"/> <field name="google_drive_folderid" attrs="{'invisible': [('backup_destination', '!=', 'google_drive')], 'required': [('backup_destination', '=', 'google_drive')]}"/>
<field name="dropbox_client_id" string="App Key" attrs="{'invisible': [('backup_destination', '!=', 'dropbox')], 'required': [('backup_destination', '=', 'dropbox')]}" password="True"/>
<field name="dropbox_client_secret" string="App Secret" attrs="{'invisible': [('backup_destination', '!=', 'dropbox')], 'required': [('backup_destination', '=', 'dropbox')]}" password="True"/>
<div>
<div attrs="{'invisible': ['|', ('backup_destination', '!=', 'dropbox'), ('is_dropbox_token_generated', '=', False)]}">
<i class="text-success fa fa-check"></i>
Refresh token set
</div>
<div attrs="{'invisible': ['|', ('backup_destination', '!=', 'dropbox'), ('is_dropbox_token_generated', '=', True)]}">
<i class="fa fa-exclamation-triangle text-warning"></i>
No refresh token set
</div>
</div>
<div>
<div attrs="{'invisible': ['|', ('backup_destination', '!=', 'dropbox'), ('is_dropbox_token_generated', '=', True)]}">
<button class="btn btn-link"
name="action_get_dropbox_auth_code"
type="object">
<i class="fa fa-arrow-right"></i>
Setup Token
</button>
</div>
<div attrs="{'invisible': ['|', ('backup_destination', '!=', 'dropbox'), ('is_dropbox_token_generated', '=', False)]}">
<button class="btn btn-link"
name="action_get_dropbox_auth_code"
type="object">
<i class="fa fa-arrow-right"></i>
Reset Token
</button>
</div>
</div>
<field name="dropbox_refresh_token" invisible="1"/>
<field name="is_dropbox_token_generated" invisible="1"/>
<field name="dropbox_folder" attrs="{'invisible': [('backup_destination', '!=', 'dropbox')], 'required': [('backup_destination', '=', 'dropbox')]}"/>
<field name="auto_remove"/> <field name="auto_remove"/>
<label for="days_to_remove" class="oe_inline" attrs="{'invisible': [('auto_remove', '=', False)]}"/> <label for="days_to_remove" class="oe_inline" attrs="{'invisible': [('auto_remove', '=', False)]}"/>
<div attrs="{'invisible': [('auto_remove', '=', False)]}"> <div attrs="{'invisible': [('auto_remove', '=', False)]}">

23
auto_database_backup/wizard/__init__.py

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2022-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
from . import dropbox_auth_code_wizard

42
auto_database_backup/wizard/dropbox_auth_code_wizard.py

@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2022-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
from odoo import models, fields, api, _
class DropboxAuthCode(models.TransientModel):
_name = 'dropbox.auth.wizard'
_description = 'Dropbox Authentication Code Wizard'
dropbox_authorization_code = fields.Char(string='Authorization Code')
dropbox_auth_url = fields.Char(string='Dropbox Authentication URL', compute='_compute_dropbox_auth_url')
@api.depends('dropbox_authorization_code')
def _compute_dropbox_auth_url(self):
backup_config = self.env['db.backup.configure'].browse(self.env.context.get('active_id'))
dropbox_auth_url = backup_config.get_dropbox_auth_url()
for rec in self:
rec.dropbox_auth_url = dropbox_auth_url
def action_setup_dropbox_token(self):
backup_config = self.env['db.backup.configure'].browse(self.env.context.get('active_id'))
backup_config.set_dropbox_refresh_token(self.dropbox_authorization_code)

27
auto_database_backup/wizard/dropbox_authcode_wizard_views.xml

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="view_dropbox_authcode_wizard_views_form" model="ir.ui.view">
<field name="name">dropbox.auth.wizard.form</field>
<field name="model">dropbox.auth.wizard</field>
<field name="arch" type="xml">
<form>
<group>
<span>Get an authorization code and set it in the field below.</span>
<field name="dropbox_auth_url"
class="fa fa-arrow-right"
widget="url"
text="Get Authorization Code"
nolabel="1"/>
</group>
<group>
<field name="dropbox_authorization_code" required="1"/>
</group>
<footer>
<button string="Confirm" type="object" name="action_setup_dropbox_token" class="btn-primary"/>
<button string="Cancel" class="btn-secondary" special="cancel"/>
</footer>
</form>
</field>
</record>
</odoo>
Loading…
Cancel
Save