Skip to content

Commit

Permalink
[MIG] auto_backup: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
michelerusti committed Jan 30, 2025
1 parent 7d70855 commit 276413a
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 50 deletions.
2 changes: 1 addition & 1 deletion auto_backup/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"name": "Database Auto-Backup",
"summary": "Backups database",
"version": "16.0.1.0.1",
"version": "18.0.1.0.0",
"author": "Yenthe Van Ginneken, "
"Agile Business Group, "
"Grupo ESOC Ingenieria de Servicios, "
Expand Down
1 change: 0 additions & 1 deletion auto_backup/data/ir_cron.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<field name="user_id" ref="base.user_root" />
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field
name="nextcall"
eval="(datetime.now() + timedelta(days=1)).strftime('%Y-%m-%d 03:00:00')"
Expand Down
6 changes: 3 additions & 3 deletions auto_backup/models/db_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def _check_folder(self):
tools.config.filestore(self.env.cr.dbname)
):
raise exceptions.ValidationError(
_(
self.env._(
"Do not save backups on your filestore, or you will "
"backup your backups too!"
)
Expand All @@ -136,7 +136,7 @@ def action_sftp_test_connection(self):
pysftp.SSHException,
) as exc:
_logger.info("Connection Test Failed!", exc_info=True)
raise UserError(_("Connection Test Failed!")) from exc
raise UserError(self.env._("Connection Test Failed!")) from exc

def action_backup(self):
"""Run selected backups."""
Expand Down Expand Up @@ -180,7 +180,7 @@ def action_backup(self):
with rec.sftp_connection() as remote:
# Directory must exist
try:
remote.makedirs(rec.folder, exist_ok=True)
remote.makedirs(rec.folder)
except pysftp.ConnectionException as exc:
_logger.exception(f"pysftp ConnectionException: {exc}")

Expand Down
96 changes: 51 additions & 45 deletions auto_backup/view/db_backup_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,61 +12,67 @@
class="oe_highlight"
/>
</header>
<div class="oe_title">
<h1>
<field name="name" />
</h1>
</div>
<group string="Basic backup configuration">
<field name="folder" />
<field name="days_to_keep" />
<field name="method" />
<field name="backup_format" />
</group>
<div attrs="{'invisible': [('method', '!=', 'sftp')]}">
<div class="bg-warning">
<h3>Warning:</h3>
Use SFTP with caution! This writes files to external servers under the path you specify.
<sheet>
<div class="oe_title">
<h1>
<field name="name" />
</h1>
</div>
<group string="SFTP Settings">
<field name="sftp_host" placeholder="sftp.example.com" />
<field name="sftp_port" />
<field name="sftp_user" placeholder="john" />
<field name="sftp_password" />
<field
name="sftp_private_key"
placeholder="/home/odoo/.ssh/id_rsa"
/>
<button
name="action_sftp_test_connection"
type="object"
string="Test SFTP Connection"
icon="fa-television"
/>
<group string="Basic backup configuration">
<field name="folder" />
<field name="days_to_keep" />
<field name="method" />
<field name="backup_format" />
</group>
</div>
<separator string="Help" colspan="2" />
<div>
Automatic backups of the database can be scheduled as follows:
<ol>
<li
>Go to Settings / Technical / Automation / Scheduled Actions.</li>
<li>Search the action named 'Backup scheduler'.</li>
<li
>Set the scheduler to active and fill in how often you want backups generated.</li>
</ol>
</div>
<div invisible="method != 'sftp'">
<div class="bg-warning">
<h3>Warning:</h3>
Use SFTP with caution! This writes files to external servers under the path you specify.
</div>
<group string="SFTP Settings">
<field name="sftp_host" placeholder="sftp.example.com" />
<field name="sftp_port" />
<field name="sftp_user" placeholder="john" />
<field name="sftp_password" />
<field
name="sftp_private_key"
placeholder="/home/odoo/.ssh/id_rsa"
/>
<button
name="action_sftp_test_connection"
type="object"
string="Test SFTP Connection"
icon="fa-television"
/>
</group>
</div>
<separator string="Help" colspan="2" />
<div>
Automatic backups of the database can be scheduled as follows:
<ol>
<li
>Go to Settings / Technical / Automation / Scheduled Actions.</li>
<li>Search the action named 'Backup scheduler'.</li>
<li
>Set the scheduler to active and fill in how often you want backups generated.</li>
</ol>
</div>
</sheet>
<chatter>
<field name="message_follower_ids" groups="base.group_user"/>
<field name="message_ids"/>
</chatter>
</form>
</field>
</record>
<record id="view_backup_conf_tree" model="ir.ui.view">
<record id="view_backup_conf_list" model="ir.ui.view">
<field name="model">db.backup</field>
<field name="arch" type="xml">
<tree>
<list>
<field name="name" />
<field name="folder" />
<field name="days_to_keep" />
</tree>
</list>
</field>
</record>
<record id="view_backup_conf_search" model="ir.ui.view">
Expand Down

0 comments on commit 276413a

Please sign in to comment.