Automated backups in Odoo

Hi guys,

In this tutorial I will learn you how to automatically take backups in Odoo, thanks to my backup module that integrates with Odoo.
There are two ways to install it, the first is through the app store and the second is by downloading it from Github.
In this guide I will explain you how to install it through Github since I like to do things myself and this will learn you how everything works. So let us start!

First download the module from Github. You can find it here. After you’ve downloaded it navigate to your Downloads folder and you’ll find a ZIP there.
Backup module download folder
Unzip this folder, you’ll now have a folder named “auto_backup-8.0”. Open this folder and you’ll see a new folder inside it named “auto_backups”.
Backup module itself
This is the actual module you will need to place inside Odoo. Now navigate to where your Odoo is located and paste the folder “auto_backup” in the “addons” folder. Like this:
Backup module in addons folder

Now that the module is under your addons folder you should first install pysftp. Pysftp is a module that offers the ability to handle all SFTP requests. My module needs this to connect to an external server, through FTP. Open up an Ubuntu terminal and run the following command:

After this you can update your module list by clicking on ‘Update Modules List’ under Settings.
Update module list
Now to go Settings > Local Modules and search for ‘Backup’.
You will see the following screen:
Module screen
Install the module from here or open up the details and then click on install.

After that the module is installed you will see a new menu item named ‘Configure Backup’ under Settings > Configuration.
New menu item
Click on this menu item and you will now see a tree view showing up. Now click on the ‘Create’ button to create a new backup.
Configure backup tree view

Now comes the greatest part, configuring the backup!
After clicking on the ‘Create’ button you will see a new screen which is almost fully filled in by default.
Configuration backup screen
Lets go over the fields one by one.

Local backup configuration:

  • Host: This is the name that you use on your local server to open up Odoo. For example if you have a local Ubuntu VM with an Odoo that you can access from http://localhost:8069/ you should fill in localhost (which is correct in 99% of the cases)! If you have http://anothername:8069/ you should fill in anothername.
  • Database: The name of the database which you want to backup. This is automatically filled in for the database you’re logged in with and should always be correct.
  • Port: The port where your Odoo runs on, on your local server! Again, open it up in your local server and take the port you use in the URL here.
  • Backup Directory: The folder where you’d like to write your backup to (locally). If you want it under /odoo/backups you write /odoo/backups.
    TIP: Be sure that the first level of the path is created (/odoo in this example) since this is directly under root and this cannot be forced. From there on Odoo can create the folders you’d like, provided that the user has enough access rights to write!
  • Auto.Remove Backups: If you check this option a new field will show up where you can specify how long you want to save backups locally. If this option is not checked the local backups will be stored forever and will not be automatically removed!
  • Remove after x days: The number that you fill in here will be the number of days that your backup should be kept locally. If you fill in 0 they will be automatically removed but can still be written to an FTP! Without keeping a local backup.

SFTP:

  • Write to external server with sftp: When you check this option you can write to an external FTP. After checking this option you will see a list of options showing up:
    SFTP details
  • IP Address SFTP Server: The IP address of your external FTP server. For example: 10.0.11.15
  • Username SFTP Server: The username where the module should login with on your external server.
  • Password User SFTP Server: The password for the user where the module should authenticate with.
  • Path external server: The absolute path where the backups should be written to on the remote FTP server. TIP: Be sure that the first folder exists if it is directly under / since the module does not have rights for this. Make sure that the user where the module logs in with also has read and write rights, so it can create folders if they don’t exist yet.
  • Remove SFTP after x days: Give in the number of days you want to keep the backups on your FTP server. All files that are longer on the FTP than the days will be automatically removed.
  • Auto. Email on backup fail: When you check this option you will automatically get an e-mail if the remote backup fails. After checking this a new field will show up where you can fill in your e-mail.TIP: You need to have an outgoing mailserver configured for this! If you do not know how check out this guide I wrote.
  • E-mail to notify: The e-mailaddress where you want to be notified in case a backup fails.

After configuring everything you should get something along this lines:
Configured backup screen
Now check if you configured everything correctly by clicking on the button ‘Test SFTP Connection’. If you get a message saying “Everything seems properly set up for FTP back-ups!” you’re almost done. If you get another message it should tell you what is wrong, just fix it!
Correctly configured

Configuring the automated action

Alright, we’re almost done! The only thing left to do now it to activate the automated action. Go to Settings > Automation > Scheduled Actions. You will see an item in the list named ‘Backup scheduler’ that is grayed out, which means it has to be activated.
Scheduled Actions
Open up the record and check the box ‘Active’ so the action will automatically run. Configure how often you wish to take a backup by specifying the ‘Interval Number’ and the ‘Interval Unit’. For example to take one backup every day at 12:00:
Daily backup configuration
Now save this and from now on all your backups will be taken automatically as you’ve configured them!

Having any problems? Liking the module? Want to give feedback? Post away! 😀
The module is available on the Odoo app store or you can get the source code from Github
Tutorial sponsored by Oocademy




115 thoughts on “Automated backups in Odoo

  1. Naduni Pulsarani says:

    I downloaded Automated Backup module here:

    https://www.odoo.com/apps/modules/8.0/auto_backup/

    I tried to paste that in Odoo Folder. I have installed Bitnami Odoo. There so many Addons folders inside the Odoo Folder. I need to find out what is the correct folder to paste this Auto-Backup Folder.

    And also I need to know how to backup data in Odoo with Windows 8. Below link shows for the Ubuntu. How I backup data in Odoo with Windows 8?

    http://www.odoo.yenthevg.com/automated-backups-in-odoo/

    Above link says that After pasting Auto-Backup folder to Addons folder, install pysftp. For installing pysftp we have to open Ubuntu Terminal. But in my machine is having Windows 8. How I manage it for Windows 8…

  2. Hi all,
    I could do backups with this module, MANY THANKS for this great module!

    But how is it to make restore of the data inclusive the filestore-data?
    I cannot any information about this.
    It would be great when you could put some notes into the REAME.md of the github project, thanks!

    • Yenthe666 says:

      Hi Peter,

      The module will by default create a .dump file. When you unzip/open this .dump file you will see there is an SQL file inside it and multiple names, which are the files (filestore data).
      So everything is by default in the dump! 🙂 (I’ll add a note on Github about this tommorow)

  3. Yenthe666 says:

    Hi gareth,

    That is really strange.. I’ve never had the problem before. Are you running an Odoo V8? Are there any errors in your logfile?

  4. Khaled Wagdy says:

    Hello I have installed the auto backup module, and defined all configuration. I believe my instance is working on port 80
    (xmlrpc_port = 80 in openerp-server.conf file)
    I created the folder /odoo/backups, but on checking their content it is empty.

    I checked server logs (openerp-server.log) and I can see the error now:
    WARNING bitnami_openerp openerp.addons.base.ir.ir_cron: Model db.backup does not exist.
    Any idea what may be causing this??

    • Yenthe666 says:

      Hi Khaled,

      Your previous comment said everything was okay but I assume it isn’t then? Cd to the location where the module is (auto_backup) and do an ls to list what is inside it. I have a feeling the folder isn’t even moved in the correct location.

      • Khaled Wagdy says:

        Hello Yenthe666,

        Here is the ls output:

        khaled@myserver:/opt/bitnami/apps/odoo/lib/odoo-8.0_20150423-py2.7.egg/openerp/addons/auto_backup$ ls -l
        total 44
        -rw-r–r– 1 khaled_wagdy khaled_wagdy 811 May 12 00:40 backup_data.xml
        -rw-r–r– 1 khaled_wagdy khaled_wagdy 14378 May 12 00:40 backup_scheduler.py
        -rw-r–r– 1 khaled_wagdy khaled_wagdy 4460 May 12 00:40 bkp_conf_view.xml
        drwxr-xr-x 2 khaled_wagdy khaled_wagdy 4096 Jul 27 17:50 i18n
        -rw-r–r– 1 khaled_wagdy khaled_wagdy 1080 May 12 00:40 __init__.py
        -rw-r–r– 1 khaled_wagdy khaled_wagdy 2525 May 12 00:40 __openerp__.py
        drwxr-xr-x 3 khaled_wagdy khaled_wagdy 4096 Jul 27 17:50 static

      • Julian says:

        I’ve purged python-dev, but if I try and install python2.7 it wants to uninstall quite a few base packages such as nmap and lots of python libraries

        ie here are a few

        python-oauth (1.0.1-3build2) …
        Removing python-openid (2.2.5-3ubuntu1) …
        Removing python-openssl

        Is this a good idea ?

        • Yenthe666 says:

          Hi Julian,

          I’m not quite sure what you have running on the system and which programs require what but this does sound like a tricky business to do. If you can and have the time I’d take a copy of your server and give this a try in the copy before doing this in a production server!

  5. Yenthe666 says:

    Hi Ravi,

    Its as simple as you say: you’re using the incorrect db password for that Odoo database. So try to figure out which is the correct one.

  6. Hi Yenthe
    Thanks again for your work with Odoo

    We want to build a module based on yours to fit our SaaS needs, adding the capability to manage the existing backups, and we wonder if you’re agree with that.

    Best regards and thanks in advance!

    • Yenthe666 says:

      Hi Mateo,

      No problem, I’m happy to see so many people can use it! Everything that I’ve written is fully open source and can be used or adapter as you like 🙂 I’d love to know what the plans are though, drop me an e-mail at yenthe.vanginneken@vanroey.be? Perhaps we can help eachother with some idea swapping.

  7. Samuel says:

    Dear all,

    I´m really worry about the installation of this module, i´ve just install an ubuntu server 14.04.3, Odoo 9.0 is running with the sample database.
    After this, i followed the tutorial and installed the module 8.0 (previosly in other O.S. i tried the same with the module 9.0 with the same problem )and during the installation the module adviced me with this sentence:

    File “/odoo/odoo-server/openerp/addons/base/ir/ir_model.py”, line 950, in xmlid_lookup
    raise ValueError(‘External ID not found in the system: %s’ % (xmlid))
    ParseError: “External ID not found in the system: base.menu_config” while parsing /odoo/odoo-server/addons/auto_backup/bkp_conf_view.xml:108, near

    Anyone knows what i made wrong?

    Thank you very much!! I really think that this app is going to be very useful!

    • Yenthe666 says:

      Hi Samuel,

      This seems to happen every once in a while when somebody wants to install the module. Simply cancel the installation, update your modules list and re-install it, this should fix it!

  8. Julian says:

    Hi

    I have a similar issue. I used your install script for odoo 9 so odoo is running under the odoo user. Installing with Ubuntu 64 bit server 14.04 was straight forward enough this time, but even though everything with the module installed perfectly, I see a sensible entry in the odoo log when I run the backup from the scheduler :-

    ie 2015-12-16 16:42:53,293 3400 INFO None openerp.service.db: DUMP DB: elite format zip

    the folder is created, everything appears fine but never are any backup files created.

    I’m happy to help debug if you can help by supplying screenshots etc and config

      • Julian says:

        Hi

        I’ve created an issue as you suggest. There are one or two thers with what looks to be quite similar issues. including the comment above mine in the blog post.

        I really need to get this working so would be pleased if you are able to provide any help with this to narrow down the issue

    • Oscar Gonzalez says:

      Iam too having same issues backing up the database. Everything installs fine but when i try to set up an automated backup it does nothing on the local directory. Also what is the difference between .dump and .zip i tried googling it but couldnt find the answer. I have tested both. with zip it seems everything copies over, however with dump i have to re-upload and set the images for the company and users. Thank you again

      • Yenthe666 says:

        Hi Oscar,

        Looks like you’ve misconfigured something. The difference between the .dump and the .zip file is exactly as you say. The dump does not contain files and images (attachments), while the zip does.

      • Julian says:

        Hello

        Unfortunately I had to give up with this method. The author wants to help but can’t replicate issue. That said a few people have had this issue, all running Ubuntu 14.04.

        There are other scripts but this one is generally well supported and get up to date.

  9. Hi, I will test this tomorrow but I’d like to clarify an item:
    This reproduces the same default backup method as /web/database/backup which consists in data and files (images, etc…) ???
    Thanks a lot

  10. Fernando Hansen says:

    This module is awsome.

    Is there any plan to port it to version 9?

    Is it possible to make the sftp password more secure? If you use the same sftp account for multiple servers, one of the admins can see the data of other companies that put their backup in the same server.

    The password is not visible (you see ******) , but if you copy paste, you can see it.

    Thanks.

    • Yenthe666 says:

      Hi Fernando,

      It is already available for version 9 on Github and the Odoo app store. I’m not sure what you’re saying about the password since back-ups are managed for a database and you need full admin rights to acces them.

  11. Christian says:

    Hi, thank you for the great app. The install functions great, but like the problem with some others, it will not do a backup.

    Looking up your answers in git and here I think it has to do with the password, but I am wondering if you have found some solution.

    To understand the problem better I want to know how should be the setup. Does the name and password of the admininistrator of the single odoo DB be the same like the Masterpassword and User? Does the programm look up the credentials directly in the odoo config?

    Sorry for maybe stupid questions, but I looked up this problem now for hours and don`t know where to look now.

    • Yenthe666 says:

      Hi Christian,

      No problem, I hope you like it. As to the configuration: a few users seem to have this issue but I have no clue what is the difference or where it goes wrong. Normally it shouldn’t be the same as the administrator, just the password and username for the specific database.

  12. Maxwell says:

    Hello All,
    How do I integrate auto_backup app with Odoo 9 on Windows 8. I am running Odoo 9 on Windows 8 but i am failing to add this app!
    Please help,

    Thanks

  13. Edser Solis says:

    Hello, great work you have been doing since ever Yenthe! Congrats!

    Please help me out on this. I’m trying to install this module on Odoo 9 and pops an error stating that I need to install pySFTP, it is already installed but still the same error pops up. I have rebooted the server and services but still the error shows up.

    • Yenthe666 says:

      Hi Edser,

      The pySFTP library had an issue for a few days regarding this. Can you try re-installing the library or update it and test it again?

      • Edser Solis says:

        Hello Yenthe, still issues persist.

        On v8 the same error shows up.
        On v9 the error is gone but the module will stay in the “Apply Scheduled Upgrades” list instead of installing. Doesn’t matter how many times I click on install, reboot the service or the server it won’t allow me to install it and remain there until I cancel the install.

        Tried installing other modules to see if the issue was with my Odoo instance but they installed just fine. I’m installing directly within the Apps menu in Odoo (the one that shows all community modules too).

        Hope you can have a check and fix on these. Your modules are awesome!

  14. Hello yenthe666,

    I would like to install this module and follow your technique but my server is without a desktop install. If you would post a modified tutorial for command line only, it would be greatly appreciated.
    thank you for your consideration.

    • Yenthe666 says:

      Hi John,

      There is no difference in the server or desktop version really. Everything you need to access visually (the Odoo front-end) can be done through the IP and all the rest can be done through the terminal?

  15. Chyn says:

    Hi

    Thanks for the module. On one of my instance where i’m running your script odoo-service seems to crash after backup When that happens i have to ssh into the server to restart the service. Have you experience that before?

    Chyn

  16. Daniel says:

    Hi Yenthe,

    Is there a way to configure the module to use standard FTP not SFTP? I have a hoster who provides an extra backup space, which is only reachable from his servers and does not accept SFTP connections. Thanks for your help!

    Daniel

    • Yenthe666 says:

      Hi Daniel,

      Nothing by default I’m afraid. You would need to add in another Python library that does FTP in place of SFTP and rewrite the core a bit.

  17. Hi!
    I’ve been trying to install pysftp on a windows environment and it’s a real pain in the… really annoying.

    I’m using the Odoo 8 installer, but even when i successfully made it to install pySFTP i don’t know where to copy the files.
    * pysftp.py
    * pysftp.pyc

    I tried C:/Program Files/Odoo 8.0/server/

    Reload the modules in Odoo but it keeps complaining about pysftp.

    Any idea about it?
    Thanks in advance 🙂

  18. John says:

    Hi Yenthe666,
    Thanks for the module, really useful and easy to setup.

    I noticed that if you have the option “list_db=false” in the odoo config file, trying to create a new backup job in your module gives the error “Validation error: No such databases”.
    If “list_db =true” or is not defined in the file, then it works fine.
    Tested on Odoo V9

    Not sure if it’s a bug or by design but kindly mention it somewhere in the blog. Took me a while to figure out what was causing the error.
    Kindly have a look when you get a chance.

    Cheers

    • Yenthe666 says:

      Hi John,

      Well it is not really made by design to give you more options. When the list_db=”false” is added to the config file there is nothing to be done about this, it disallows Odoo from listing/fetching the databases, which means I cannot take the back-up either. I’ll mention it in my post somewhere soon. Thanks for letting me know.

  19. Cemhan Senturk says:

    Hi Yenthe,
    Auto backup give me error. Error is;
    Connection Test Failed!
    Here is what we got instead:
    No hostkey for host 46.101.xxx.xxx found.
    How can I solve it?
    Thanks.

  20. Hi,
    I am using your auto-backup script which seems to work for me. I even backup to a remote server. Now, I noticed that when I setup a new database and try to test the ftp connection to my remote server, I get the following error in Odoo autobackup setup page.
    No hostkey for host x.x.x.x found.

    Any clue please?
    Thanks

  21. Manuel says:

    Hello!
    thanks for this amazing software!
    But I can´t install the pysftp, I get this result in my terminal. I am running Ubuntu 12.04.5 LTS

    Please any suggestion:

    root@myserver:/odoo/odoo8/addons# sudo pip install pysftp
    Downloading/unpacking pysftp
    Downloading pysftp-0.2.9.tar.gz
    Running setup.py egg_info for package pysftp

    no previously-included directories found matching ‘docs/_build’
    Downloading/unpacking paramiko>=1.17 (from pysftp)
    Downloading paramiko-2.0.2.tar.gz (1.2Mb): 1.2Mb downloaded
    Running setup.py egg_info for package paramiko

    Downloading/unpacking cryptography>=1.1 (from paramiko>=1.17->pysftp)
    Downloading cryptography-1.4.tar.gz (399Kb): 399Kb downloaded
    Running setup.py egg_info for package cryptography

    no previously-included directories found matching ‘docs/_build’
    warning: no previously-included files matching ‘*’ found under directory ‘vectors’
    Downloading/unpacking pyasn1>=0.1.7 (from paramiko>=1.17->pysftp)
    Downloading pyasn1-0.1.9.tar.gz (75Kb): 75Kb downloaded
    Running setup.py egg_info for package pyasn1

    Downloading/unpacking idna>=2.0 (from cryptography>=1.1->paramiko>=1.17->pysftp)
    Downloading idna-2.1.tar.gz (128Kb): 128Kb downloaded
    Running setup.py egg_info for package idna

    warning: no previously-included files matching ‘*.pyc’ found under directory ‘tools’
    warning: no previously-included files matching ‘*.pyc’ found under directory ‘tests’
    Downloading/unpacking six>=1.4.1 (from cryptography>=1.1->paramiko>=1.17->pysftp)
    Downloading six-1.10.0.tar.gz
    Running setup.py egg_info for package six

    no previously-included directories found matching ‘documentation/_build’
    Requirement already satisfied (use –upgrade to upgrade): distribute in /usr/lib/python2.7/dist-packages (from cryptography>=1.1->paramiko>=1.17->pysftp)
    Downloading/unpacking enum34 (from cryptography>=1.1->paramiko>=1.17->pysftp)
    Downloading enum34-1.1.6.tar.gz (40Kb): 40Kb downloaded
    Running setup.py egg_info for package enum34

    Downloading/unpacking ipaddress (from cryptography>=1.1->paramiko>=1.17->pysftp)
    Downloading ipaddress-1.0.16.tar.gz
    Running setup.py egg_info for package ipaddress

    Downloading/unpacking cffi>=1.4.1 (from cryptography>=1.1->paramiko>=1.17->pysftp)
    Downloading cffi-1.7.0.tar.gz (400Kb): 400Kb downloaded
    Running setup.py egg_info for package cffi
    unable to execute gcc: No such file or directory
    unable to execute gcc: No such file or directory

    No working compiler found, or bogus compiler options
    passed to the compiler from Python’s distutils module.
    See the error messages above.
    (If they are about -mno-fused-madd and you are on OS/X 10.8,
    see http://stackoverflow.com/questions/22313407/ .)
    Complete output from command python setup.py egg_info:
    unable to execute gcc: No such file or directory

    unable to execute gcc: No such file or directory

    No working compiler found, or bogus compiler options

    passed to the compiler from Python’s distutils module.

    See the error messages above.

    (If they are about -mno-fused-madd and you are on OS/X 10.8,

    see http://stackoverflow.com/questions/22313407/ .)

    —————————————-
    Command python setup.py egg_info failed with error code 1
    Storing complete log in /root/.pip/pip.log
    root@myserver:/odoo/odoo8/addons#

  22. Hammer says:

    Hi!

    Thanks for this very good tutorial. I tested your autobackup app and it works for me.
    Is it possible to create more complex backup-and-housekeeping-procedures?
    Like this, daily backup store 14 days; weekly backup store 52 weeks; monthly backup store forever.

    Thanks!

    • Yenthe666 says:

      Hi Hammer,

      You’re very welcome. All the things you want to do can be done but require some extra development. The easiest way is to probably create multiple schedulers with the specific configuration of when you want the back-ups to be taken.

    • Yenthe666 says:

      Hi Mike,

      Thanks a lot! The migration to V10 will happen but I haven’t had time for it yet, give me a few weeks.
      P.S: a PR is always welcome on Github too 😉

  23. Moises Garcia says:

    Hi, Yenthe. Do you think it would be possible to develope a paid customization so that your backup module works with Google Drive?

    I.E.: Backup the database in Google Drive using a scheduler in Odoo, and also limit the number of backups (delete older ones).

    Thanks in advance!

  24. Michael Soo says:

    I tried to install the app but I got this error. Can anyone help??

    Traceback (most recent call last):
    File “/odoo/odoo-server/odoo/http.py”, line 638, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
    File “/odoo/odoo-server/odoo/http.py”, line 675, in dispatch
    result = self._call_function(**self.params)
    File “/odoo/odoo-server/odoo/http.py”, line 331, in _call_function
    return checked_call(self.db, *args, **kwargs)
    File “/odoo/odoo-server/odoo/service/model.py”, line 101, in wrapper
    return f(dbname, *args, **kwargs)
    File “/odoo/odoo-server/odoo/http.py”, line 324, in checked_call
    result = self.endpoint(*a, **kw)
    File “/odoo/odoo-server/odoo/http.py”, line 933, in __call__
    return self.method(*args, **kw)
    File “/odoo/odoo-server/odoo/http.py”, line 504, in response_wrap
    response = f(*args, **kw)
    File “/odoo/odoo-server/addons/web/controllers/main.py”, line 889, in call_button
    action = self._call_kw(model, method, args, {})
    File “/odoo/odoo-server/addons/web/controllers/main.py”, line 877, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
    File “/odoo/odoo-server/odoo/api.py”, line 681, in call_kw
    return call_kw_multi(method, model, args, kwargs)
    File “/odoo/odoo-server/odoo/api.py”, line 672, in call_kw_multi
    result = method(recs, *args, **kwargs)
    File “/odoo/odoo-server/odoo/addons/base/module/module.py”, line 410, in button_immediate_install
    return self._button_immediate_function(type(self).button_install)
    File “/odoo/odoo-server/odoo/addons/base/module/module.py”, line 484, in _button_immediate_function
    modules.registry.Registry.new(self._cr.dbname, update_module=True)
    File “/odoo/odoo-server/odoo/modules/registry.py”, line 82, in new
    odoo.modules.load_modules(registry._db, force_demo, status, update_module)
    File “/odoo/odoo-server/odoo/modules/loading.py”, line 339, in load_modules
    loaded_modules, update_module)
    File “/odoo/odoo-server/odoo/modules/loading.py”, line 237, in load_marked_modules
    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
    File “/odoo/odoo-server/odoo/modules/loading.py”, line 156, in load_module_graph
    _load_data(cr, module_name, idref, mode, kind=’data’)
    File “/odoo/odoo-server/odoo/modules/loading.py”, line 95, in _load_data
    tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
    File “/odoo/odoo-server/odoo/tools/convert.py”, line 845, in convert_file
    convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
    File “/odoo/odoo-server/odoo/tools/convert.py”, line 915, in convert_xml_import
    obj.parse(doc.getroot(), mode=mode)
    File “/odoo/odoo-server/odoo/tools/convert.py”, line 796, in parse
    self.parse(rec, mode)
    File “/odoo/odoo-server/odoo/tools/convert.py”, line 799, in parse
    self._tags[rec.tag](rec, de, mode=mode)
    File “/odoo/odoo-server/odoo/tools/convert.py”, line 707, in _tag_record
    id = self.env(context=rec_context)[‘ir.model.data’]._update(rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode)
    File “/odoo/odoo-server/odoo/addons/base/ir/ir_model.py”, line 1228, in _update
    record = record.create(values)
    File “/odoo/odoo-server/odoo/addons/base/ir/ir_ui_view.py”, line 360, in create
    return super(View, self).create(self._compute_defaults(values))
    File “/odoo/odoo-server/odoo/models.py”, line 3838, in create
    self._fields[key].determine_inverse(record)
    File “/odoo/odoo-server/odoo/fields.py”, line 1000, in determine_inverse
    getattr(records, self.inverse)()
    File “/odoo/odoo-server/odoo/addons/base/ir/ir_ui_view.py”, line 220, in _inverse_arch
    view.write(data)
    File “/odoo/odoo-server/odoo/addons/base/ir/ir_ui_view.py”, line 378, in write
    return super(View, self).write(self._compute_defaults(vals))
    File “/odoo/odoo-server/odoo/models.py”, line 3564, in write
    self._write(old_vals)
    File “/odoo/odoo-server/odoo/models.py”, line 3715, in _write
    self._validate_fields(vals)
    File “/odoo/odoo-server/odoo/models.py”, line 1083, in _validate_fields
    raise ValidationError(“%s\n\n%s” % (_(“Error while validating constraint”), tools.ustr(e)))
    ParseError: “Error while validating constraint

    Model not found: db.backup

    Error context:
    View Configure Backup
    [view_id: 629, xml_id: n/a, model: db.backup, parent_id: n/a]
    None” while parsing /odoo/odoo-server/odoo/addons/auto_backup/views/bkp_conf_view.xml:4, near

    Configure Backup
    db.backup
    form

    Warning: Use SFTP with caution! This writes files to external servers under the path you specify.

    This configures the scheduler for automatic backup of the given database running on given host at given port on regular intervals.

    Automatic backups of the database can be scheduled as follows:

    Go to Settings / Technical / Automation / Scheduled Actions.

    Search the action named ‘Backup scheduler’.

    Set the scheduler to active and fill in how often you want backups generated.

    Need more help? Contact us!

  25. Paul says:

    Hi, lovely module.
    Was very happy to have it running, even with sftp backup to my local server.
    But…. sadly it broke somehow.

    Error ! No such database exists!

    The strange thing is that on a testserver copy , 2 weeks old it still works, i compare and compare and dont find the cause, all is indentical or not the cause as far i tested.

    He dont write any database anymore in the folder, nor do a SFTP connection.

    This is the odoo-server.log:

    2017-09-05 19:37:27,779 2469 INFO None werkzeug: 127.0.0.1 – – [05/Sep/2017 19:37:27] “POST /xmlrpc/db HTTP/1.1” 200 –
    2017-09-05 19:37:27,781 2469 ERROR DatabaseMain odoo.addons.base.ir.ir_cron: Call of self.env[u’db.backup’].schedule_backup(*()) failed in Job #15
    Traceback (most recent call last):
    File “/usr/lib/python2.7/dist-packages/odoo/addons/base/ir/ir_cron.py”, line 118, in _callback
    getattr(model, method_name)(*args)
    File “/opt/custom_addons/auto_backup/models/db_backup.py”, line 138, in schedule_backup
    db_list = self.get_db_list(rec.host, rec.port)
    File “/opt/custom_addons/auto_backup/models/db_backup.py”, line 62, in get_db_list
    db_list = execute(conn, ‘list’)
    File “/opt/custom_addons/auto_backup/models/db_backup.py”, line 48, in execute
    res = getattr(connector,method)(*args)
    File “/usr/lib/python2.7/xmlrpclib.py”, line 1243, in __call__
    return self.__send(self.__name, args)
    File “/usr/lib/python2.7/xmlrpclib.py”, line 1602, in __request
    verbose=self.__verbose
    File “/usr/lib/python2.7/xmlrpclib.py”, line 1283, in request
    return self.single_request(host, handler, request_body, verbose)
    File “/usr/lib/python2.7/xmlrpclib.py”, line 1316, in single_request
    return self.parse_response(response)
    File “/usr/lib/python2.7/xmlrpclib.py”, line 1493, in parse_response
    return u.close()
    File “/usr/lib/python2.7/xmlrpclib.py”, line 800, in close
    raise Fault(**self._stack[0])
    Fault:
    2017-09-05 19:37:27,783 2469 INFO DatabaseMain werkzeug: 127.0.0.1 – – [05/Sep/2017 19:37:27] “POST /web/dataset/call_button HTTP/1.0” 200 –
    2017-09-05 19:37:27,836 2469 INFO DatabaseMain werkzeug: 127.0.0.1 – – [05/Sep/2017 19:37:27] “POST /web/dataset/call_kw/ir.cron/search_read HTTP/1.0” 200 –
    2017-09-05 19:37:27,887 2469 INFO DatabaseMain werkzeug: 127.0.0.1 – – [05/Sep/2017 19:37:27] “POST /web/dataset/search_read HTTP/1.0” 200 –

    And this is the Error Message in the Backend, when trying the SFTP connection test:

    Traceback (most recent call last):
    File “/usr/lib/python2.7/dist-packages/Database/http.py”, line 640, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
    File “/usr/lib/python2.7/dist-packages/Database/http.py”, line 677, in dispatch
    result = self._call_function(**self.params)
    File “/usr/lib/python2.7/dist-packages/Database/http.py”, line 333, in _call_function
    return checked_call(self.db, *args, **kwargs)
    File “/usr/lib/python2.7/dist-packages/Database/service/model.py”, line 101, in wrapper
    return f(dbname, *args, **kwargs)
    File “/usr/lib/python2.7/dist-packages/Database/http.py”, line 326, in checked_call
    result = self.endpoint(*a, **kw)
    File “/usr/lib/python2.7/dist-packages/Database/http.py”, line 935, in __call__
    return self.method(*args, **kw)
    File “/usr/lib/python2.7/dist-packages/Database/http.py”, line 506, in response_wrap
    response = f(*args, **kw)
    File “/usr/lib/python2.7/dist-packages/Database/addons/web/controllers/main.py”, line 889, in call_button
    action = self._call_kw(model, method, args, {})
    File “/usr/lib/python2.7/dist-packages/Database/addons/web/controllers/main.py”, line 877, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
    File “/usr/lib/python2.7/dist-packages/Database/api.py”, line 681, in call_kw
    return call_kw_multi(method, model, args, kwargs)
    File “/usr/lib/python2.7/dist-packages/Database/api.py”, line 672, in call_kw_multi
    result = method(recs, *args, **kwargs)
    File “/opt/custom_addons/auto_backup/models/db_backup.py”, line 110, in test_sftp_connection
    db_list = self.get_db_list(rec.host, rec.port)
    File “/opt/custom_addons/auto_backup/models/db_backup.py”, line 62, in get_db_list
    db_list = execute(conn, ‘list’)
    File “/opt/custom_addons/auto_backup/models/db_backup.py”, line 48, in execute
    res = getattr(connector,method)(*args)
    File “/usr/lib/python2.7/xmlrpclib.py”, line 1243, in __call__
    return self.__send(self.__name, args)
    File “/usr/lib/python2.7/xmlrpclib.py”, line 1602, in __request
    verbose=self.__verbose
    File “/usr/lib/python2.7/xmlrpclib.py”, line 1283, in request
    return self.single_request(host, handler, request_body, verbose)
    File “/usr/lib/python2.7/xmlrpclib.py”, line 1316, in single_request
    return self.parse_response(response)
    File “/usr/lib/python2.7/xmlrpclib.py”, line 1493, in parse_response
    return u.close()
    File “/usr/lib/python2.7/xmlrpclib.py”, line 800, in close
    raise Fault(**self._stack[0])
    Fault:

    But as i say he dont even write the dump anymore to the given folder, the sftp still wroks from the little older copied server, so all setting where tested.
    No Clue )-: would love to have my backup working

  26. regis says:

    Hi Yenthe,
    Thank you for this great app ! it just works perfectly on a daily basis. I have one request though:
    Is there a way to configure the format of the archive name somewhere ?
    archives are named after: DD_MM_YYYY_hh_mm_ss
    this is not the best way in my honest opinion, because when sorting the file list on a backup folder, the chronology is not respected. you would find :
    02_07_2017…
    02_08_2017…
    02_09_2017…
    03_07_2017…
    03_08_2017…
    03_09_2017…
    The best format would be starting with the largest time unit :
    YYYY_MM_DD_hh_mm_ss
    so that the list would be:
    2017_07_02..
    2017_07_03…
    ….
    2017_08_02…
    2017_08_03…

    etc
    Is there some way to do this ?
    Best regards,
    Regis

  27. Kingsley says:

    Hi, Thanks for the module. It is really helpful. Is it advisable to run backup scheduler during working hours? especially while the users are using the system. Is there any side effect, like data corruption?

  28. nguyentuan says:

    Hi Yenthe,
    I am using odoo 9 and your module work like a charm. But my backup files was 1.5 Gb, and it increase day after day. So I want to ask you what should I do in this case, because it can not restore by normal way. I think I must restore by command line. Can you help me?
    Thank a lot!

        • Yenthe666 says:

          Hi Philippe,

          The .dump file would be generated by the Odoo backup module itself. You can use backup to restore the database from the command line. Something along the lines of:
          pg_restore -O -x -d upgraded_dbname < upgraded_dbdump.dum

          • nguyentuan says:

            But if we restore this .dump file, we will lost all images, attachments … So how can we do this?

          • Yenthe666 says:

            Hi nguyentuan,

            You will need to copy the filestore from one location to another in order to fix this issue.

  29. Dany says:

    Hi Yenthe,
    First of all thank you for sharing your great work……

    Most probable you are aware on Odoo 11, the backup works only once, after Odoo start (manually or Scheduled).
    Do you have a temporary solution, until you will be able to have ready the rebuild version?
    Best regards.

  30. Hi,
    Thanks for the great addon but I got this error trying to create a new configuration:

    Fault AccessDenied: ‘Access denied

    I’m using the default information, localhost:8069, and the database name is correct. I’m not sure what happened.

    Any idea?

  31. Alexandru Gagea says:

    If i copy/paste the auto_backup module into the addons folder, it breaks odoo enterprise. Meaning i get a blank page with the bellow error from the Chrome console :

    Uncaught Error: QWeb2: Template ‘ActionManager’ not found
    at Object.exception (web.assets_common.js:3689)
    at Engine._render (web.assets_common.js:3734)
    at Engine.render (web.assets_common.js:3730)
    at Class.renderElement (web.assets_common.js:3943)
    at web.assets_common.js:3943
    at web.assets_common.js:802
    at fire (web.assets_common.js:796)
    at Object.add [as done] (web.assets_common.js:797)
    at Array. (web.assets_common.js:802)
    at Function.each (web.assets_common.js:625).

    if i remove the module from the addons folder and reboot the linux server.. all works fine.

    Any ideas Yenthe ?

    Thank you,
    Alex

    • Yenthe666 says:

      Hi Alexandre,

      Thanks for the feedback. Try to update the module with the – u command. If that doesn’t work then please make a bug report on the Github repository.

  32. Hi. My odoo running and using masterpassword.

    I install your module in my vps, and i do backup localy. But, the backup doesnt created. i locate the backup on /odoo/backups

    the user of odoo database is “ety”

    the owner of the /odoo and /odoo/backups is root
    and i do chmod 777 -r to the folder.

    Can you help me to run this module? Thanks

  33. Ulrich says:

    Hi @yenthe666
    Please
    For the installation of pysftp, I installed python3.7. I managed to install pysftp via the ‘pip install pysftp’ command in the cmd. But when installing the module, I always have the same error message asking me to install pysftp.
    I can not install pysftp for odoo comunity v9 on windows7. Please, how to do it?

  34. katmai says:

    i am trying to install this module in odoo11 but i just can’t find the “update modules list” that you mentioned. tried looking through the other comments but didn’t find what im doing wrong. i also restarted the odoo server and went to the apps list and i don’t see the module there either.

  35. Tim says:

    Hi Yenthe,

    We used your tool to backup an community database. We now want to recover be see that the images of products are not recoverd. also some icons of the installed enterprise look free theme are also gone.

    Do you have any advice how to get those back?

    Thank you!

    Kind regards,

    Tim

    • Yenthe666 says:

      Hi Tim,

      The attachments in Odoo are stored in a separate folder on the system. You can just copy them over for the new database in the right folder and they’ll be used.
      P.S: You should be able to see warnings in the log telling you something like this too.

  36. Juan Pablo Barragán says:

    Hello Yenthe,

    I don’t know what am I doing wrong.I tried in 2 different Odoo 11 deployments (both of them installed with your script), but after putting the module in the addons folder, installing pysftp with
    sudo pip install pysftp and restarting the server, when I log in into my database I always get a blank screen with just Odoo logo and no menus.

    Any clues?

    • Yenthe666 says:

      Hi Juan,

      Do the same proces while looking at the output of the logfile. There is a probably a sub package missing or giving errors. You should see it in the logs after a restart and then doing the whole flow again.

  37. Afthab Sayed says:

    Hello, I have installed auto_backup module for version 11.0 and i found an error while manually running the scheduled action ‘Backup scheduler’.

    Traceback (most recent call last):
    File “/home/afthab/Documents/odoo/odoo11/odoo/tools/safe_eval.py”, line 348, in safe_eval
    return unsafe_eval(c, globals_dict, locals_dict)
    File “”, line 1, in
    File “/home/afthab/Documents/odoo/odoo11/caddons/test/auto_backup/models/db_backup.py”, line 152, in schedule_backup
    os.makedirs(rec.folder)
    File “/usr/lib/python3.5/os.py”, line 231, in makedirs
    makedirs(head, mode, exist_ok)
    File “/usr/lib/python3.5/os.py”, line 241, in makedirs
    mkdir(name, mode)
    PermissionError: [Errno 13] Permission denied: ‘/home/Documents’

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File “/home/afthab/Documents/odoo/odoo11/odoo/http.py”, line 650, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
    File “/home/afthab/Documents/odoo/odoo11/odoo/http.py”, line 310, in _handle_exception
    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
    File “/home/afthab/Documents/odoo/odoo11/odoo/tools/pycompat.py”, line 87, in reraise
    raise value
    File “/home/afthab/Documents/odoo/odoo11/odoo/http.py”, line 692, in dispatch
    result = self._call_function(**self.params)
    File “/home/afthab/Documents/odoo/odoo11/odoo/http.py”, line 342, in _call_function
    return checked_call(self.db, *args, **kwargs)
    File “/home/afthab/Documents/odoo/odoo11/odoo/service/model.py”, line 97, in wrapper
    return f(dbname, *args, **kwargs)
    File “/home/afthab/Documents/odoo/odoo11/odoo/http.py”, line 335, in checked_call
    result = self.endpoint(*a, **kw)
    File “/home/afthab/Documents/odoo/odoo11/odoo/http.py”, line 936, in __call__
    return self.method(*args, **kw)
    File “/home/afthab/Documents/odoo/odoo11/odoo/http.py”, line 515, in response_wrap
    response = f(*args, **kw)
    File “/home/afthab/Documents/odoo/odoo11/addons/web/controllers/main.py”, line 935, in call_button
    action = self._call_kw(model, method, args, {})
    File “/home/afthab/Documents/odoo/odoo11/addons/web/controllers/main.py”, line 923, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
    File “/home/afthab/Documents/odoo/odoo11/odoo/api.py”, line 689, in call_kw
    return call_kw_multi(method, model, args, kwargs)
    File “/home/afthab/Documents/odoo/odoo11/odoo/api.py”, line 680, in call_kw_multi
    result = method(recs, *args, **kwargs)
    File “/home/afthab/Documents/odoo/odoo11/odoo/addons/base/ir/ir_cron.py”, line 76, in method_direct_trigger
    self.sudo(user=cron.user_id.id).ir_actions_server_id.run()
    File “/home/afthab/Documents/odoo/odoo11/odoo/addons/base/ir/ir_actions.py”, line 545, in run
    res = func(action, eval_context=eval_context)
    File “/home/afthab/Documents/odoo/odoo11/odoo/addons/base/ir/ir_actions.py”, line 421, in run_action_code_multi
    safe_eval(action.sudo().code.strip(), eval_context, mode=”exec”, nocopy=True) # nocopy allows to return ‘action’
    File “/home/afthab/Documents/odoo/odoo11/odoo/tools/safe_eval.py”, line 371, in safe_eval
    pycompat.reraise(ValueError, ValueError(‘%s: “%s” while evaluating\n%r’ % (ustr(type(e)), ustr(e), expr)), exc_info[2])
    File “/home/afthab/Documents/odoo/odoo11/odoo/tools/pycompat.py”, line 86, in reraise
    raise value.with_traceback(tb)
    File “/home/afthab/Documents/odoo/odoo11/odoo/tools/safe_eval.py”, line 348, in safe_eval
    return unsafe_eval(c, globals_dict, locals_dict)
    File “”, line 1, in
    File “/home/afthab/Documents/odoo/odoo11/caddons/test/auto_backup/models/db_backup.py”, line 152, in schedule_backup
    os.makedirs(rec.folder)
    File “/usr/lib/python3.5/os.py”, line 231, in makedirs
    makedirs(head, mode, exist_ok)
    File “/usr/lib/python3.5/os.py”, line 241, in makedirs
    mkdir(name, mode)
    ValueError: : “13
    Permission denied” while evaluating
    ‘model.schedule_backup()’

    • Yenthe666 says:

      Hi,

      Not really an error. The Odoo user does not have enough rights in this folder so can’t create folders on itself. If you create the folder manually and set the rights it’ll work fine.

Leave a Reply