Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

How to script database backup on Ubuntu?

Naroči se

Get notified when there's activity on this post

This question has been flagged
databaseubuntuscriptbackupdump
2 Odgovori
8076 Prikazi
Avatar
Pascal Tremblay

???

0
Avatar
Opusti
Avatar
Pascal Tremblay
Avtor Best Answer

Script name : odoo.db.backup.quotidien.sh

This script is executed two times a day via cron. 

This script dump the actual odoo database, create a new db and import data in this new database.

You can after run Odoo with the database you want.

It's really magic to make test on actual database. Each morning, I have a new fresh copy of my actual database and I can log in it if I want.

For the moment, the script doesn't erase the older created databases. 

For the moment, the script stops Odoo to make the dump. We didn't try without to stop Odoo.

Here is our script :

#!/bin/bash

clear

DATABASE="officielle"
NOW=$(date +"%d-%m-%Y_%H-%M")
NOMDUFICHIER="/home/flooder/Bureau/odoo_quotidien_$DATABASE_$NOW.sql"

NEWDB="odoo_quotidien_$NOW" 

echo "1) Arrêt de Odoo..."
/home/flooder/Programmes/StopOdoo.sh

echo
echo "2) Nettoyage du fichier journal..."
> /home/flooder/Programmes/log/odoo.db.backup.quotidien.log
echo
echo "3) Préparation de la sauvegarde de la base de données Odoo... " 


export PGPASSWORD="lsssls"
echo


echo "4) Exportation (dump) de la base de données..."
echo "   + dans le fichier : $NOMDUFICHIER"
echo "   + de la base de données : $DATABASE"
echo
/usr/bin/pg_dump --host localhost --port 5432 -E UTF-8 --format plain --verbose --username "odoo"  --format plain  --file $NOMDUFICHIER $DATABASE 2>>/home/flooder/Programmes/log/odoo.db.backup.quotidien.log

chown flooder:flooder /home/flooder/Programmes/log/odoo.db.backup.quotidien.log
chmod 755 /home/flooder/Programmes/log/odoo.db.backup.quotidien.log
chown flooder:flooder $NOMDUFICHIER
chmod 755 $NOMDUFICHIER

echo
echo "5) Création d'une nouvelle base de données..."
if [[ `psql -U odoo -d postgres -tAc "SELECT 1 FROM pg_database WHERE datname='$NEWDB' " ` == "1" ]]
then
    echo "   + $NEWDB existe déjà. Nous allons la détruire."
        MESSAGE=$(/usr/bin/dropdb -U "odoo" --echo --port 5432  $NEWDB 2>>/home/flooder/Programmes/log/odoo.db.backup.quotidien.log)
        echo "   + message de la destruction : $MESSAGE" 
else
        echo "   + $NEWDB n'existe pas. Nous allons la créer."

     #2>>/home/flooder/Programmes/log/odoo.db.backup.quotidien.log
     
fi
        echo "   + création de la nouvelle base de données : $NEWDB"
        /usr/bin/createdb --encoding=UTF-8 -U "odoo" $NEWDB 2>>/home/flooder/Programmes/log/odoo.db.backup.quotidien.log
echo 


echo "6) Importation des données dans la nouvelle base de données..."
echo "   + du fichier : $NOMDUFICHIER"
echo "   + dans la base de données : $NEWDB"

/usr/bin/psql -U odoo $NEWDB < $NOMDUFICHIER 2>>/home/flooder/Programmes/log/odoo.db.backup.quotidien.log


echo
#2>>/home/flooder/Programmes/log/odoo.db.backup.quotidien.log
echo

echo "7) Redémarrage Odoo"
/home/flooder/Programmes/RestartOdoo.sh


echo "8) Envoi du courriel de confirmation"


FILESIZE=$( stat -c %s /home/flooder/Programmes/log/odoo.db.backup.quotidien.log)
echo "   + le fichier journal à envoyer à une taille : $FILESIZE octets"
sendEmail -f pt@lapagept.com -t pt@lapagept.com -u "Sync PT - quotidien - Odoo" -m "Synchronisation de Odoo terminee." -s mail.lapagept.com:26 -xu pt@lapagept.com -xp einegeineg25$ -a /home/flooder/Programmes/log/odoo.db.backup.quotidien.log
exit

1
Avatar
Opusti
Avatar
Zbik
Best Answer

My suggestion is to use the standard package in Ubuntu - autopostgresqlbackup.

0
Avatar
Opusti
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Prijavi
Related Posts Odgovori Prikazi Aktivnost
Database Backup not working
database backup dump
Avatar
Avatar
2
mar. 15
6700
Why do I get these errors when I import a backup in my database? Solved
import database backup dump
Avatar
Avatar
2
dec. 17
6141
Why does my database import on Windows 7 fail with an Ubuntu database?
windows import database ubuntu dump
Avatar
0
mar. 15
5386
Automated backups
backup dump
Avatar
Avatar
Avatar
2
dec. 24
2140
Database size change
database backup
Avatar
1
nov. 23
5005
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now