1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# This module copyright (C) 2011-2012 Therp BV (<http://therp.nl>)
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation, either version 3 of the License, or
11
# (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
##############################################################################
22
from openerp.osv.orm import TransientModel,except_orm
24
from openerp.tools.translate import _
26
class trp_backup_wizard(TransientModel):
27
_inherit='trp_backup.wizard'
29
def do_backup(self, cr, uid):
30
success, messages, backup_file=super(trp_backup_wizard, self).do_backup(cr,
35
params=self.pool.get('ir.config_parameter')
36
rsync_host=self.pool.get('ir.config_parameter').get_param(cr, uid,
37
'trp_backup_rsync.host')
39
self._logger.info(_('copying %s to %s')%(backup_file,rsync_host))
43
rsync_process=subprocess.Popen(['rsync',
47
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
49
output=rsync_process.communicate()
51
if rsync_process.returncode==0:
52
messages+=_('Sucessfully copied %s to %s')%(backup_file,
54
messages+=(output[0]+'\n') if output[0] else ''
55
messages+=(output[1]+'\n') if output[1] else ''
58
messages+=_('There was an error during transfer:')+'\n'
59
messages+=(output[0]+'\n') if output[0] else ''
60
messages+=(output[1]+'\n') if output[1] else ''
61
if rsync_process.returncode not in [23,30,35]:
64
self._logger.info(messages)
66
self._logger(_('Backup failed, not running transfer'))
68
return success, messages, backup_file