"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?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project
- MRP
This question has been flagged
Hi,
Try below command may help you
pg_dump -U <DB Username> <DB Name> > backup.sql
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:
os.mkdir(dump_dir)
# 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:
os.unlink(filename)
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:
f.write(string)
def start():
unlinked = clean(days=40)
for db in DATABASES:
dump(db)
log('done | {} old archive(s) deleted | {} new archive(s) created'.format(unlinked, len(DATABASES)))
start()
In the start function, change days=40 means that your db archives will stay 40 days before beeing cleaned.
After backup ,What is the restore command?
DB=dbname && createdb $DB && pg_restore -n public --no-acl -O -d $DB
Here What is dbname?, $DB ? O -d $DB ?
DB=dbname && createdb $DB && pg_restore -n public --no-acl -O -d $DB
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up