Odoo Help


How can i take backup of database without using the "manage database link", Psql command , and pgadmin 3?

on 9/10/14, 4:00 AM 2,002 views

"Manage database" link showing at the time of login. So any user can click on that and if he know the password of DB can drop it. In my point of view giving "Manage database" link in login screen is not that much secure. I can hide that link by inheriting web module. But the problem is to take backup of DB i have to connect to "server" and need to write the pgsql commands to take backup of db. What's my actual requirement is, can any one give the "path" of manage database. <a href="#" class="oe_login_manage_db">Manage Databases</a> is the manage database anchor tab. Where it is going when i clik on this link. So I saved that path some where in my mail. If i want to take back up of DB, i directly copy that path in browser and take back up. Or else is there any way to take backup without using the "manage database link", Psql command , and pgadmin 3?


Jagdish Panchal

--Jagdish Panchal--

| 5 4 6
Gandhinagar, India
--Jagdish Panchal--

OpenERP Developer

Jagdish Panchal
On 9/29/14, 5:18 AM


Try below command may help you

pg_dump -U <DB Username> <DB Name>  >  backup.sql

On 9/10/14, 4:41 AM

Put it in a file, then run a cron on it:

#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import time
from subprocess import Popen, PIPE
import glob

BACKUP_DIR = '/path/to/some/backup/directory/'
LOG_FILE = '{}backup.log'.format(BACKUP_DIR)
USER = 'username'
DATABASES = ['foo', 'bar']

def dump(db_name):
    dump_dir = BACKUP_DIR + db_name + '/'
    # check if dump_dir exists, create it if not
    dump_dir_glob = glob.glob(dump_dir)
    if len(dump_dir_glob) == 0:
    # dump db
    now = int(time.time() * 1000000)
    dump_file_path = '{}{}_{}.dump'.format(dump_dir, db_name, now)
    with open(dump_file_path, 'wb') as dump_file, \
            open(LOG_FILE, 'a') as log_file:
        process = Popen(['pg_dump', '-Fc', db_name, '-U', USER], stdout=dump_file, stderr=log_file)

def clean(days=2, hours=0, minutes=0, seconds=0):
    interval = seconds + minutes*60 + hours*60*60 + days*24*60*60
    x_days_ago = time.time() - interval
    unlinked = 0
    for db_name in DATABASES:
        glob_list = glob.glob('{}{}/*'.format(BACKUP_DIR, db_name))
        for filename in glob_list:
            file_info = os.stat(filename)
            if file_info.st_ctime < x_days_ago:
                unlinked += 1
    return unlinked

def log(string):
    now = time.strftime('%d-%m-%Y_%H:%M:%S')
    string = '{} >> {}\n'.format(now, string)
    with open(LOG_FILE, 'a') as f:

def start():
    unlinked = clean(days=40)
    for db in DATABASES:
    log('done | {} old archive(s) deleted | {} new archive(s) created'.format(unlinked, len(DATABASES)))


In the start function, change days=40 means that your db archives will stay 40 days before beeing cleaned.

on 9/10/14, 4:43 AM
On 9/29/14, 4:41 AM

After backup ,What is the restore command?

DB=dbname && createdb $DB && pg_restore -n public --no-acl -O -d $DB

Hiral Patel (hip)
on 9/29/14, 4:42 AM

Here What is dbname?, $DB ? O -d $DB ?

on 9/29/14, 5:49 AM

DB=dbname && createdb $DB && pg_restore -n public --no-acl -O -d $DB

Hiral Patel (hip)
on 9/29/14, 6:01 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 9/10/14, 4:00 AM
Seen: 2002 times
Last updated: 3/16/15, 8:10 AM