Odoo Help

Welcome!

This community 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.

0

error: relation "account_invoice_cancel" already exists - when I dump database

By
Pascal Tremblay
on 11/12/14, 8:09 AM 982 views

Hello everybody,

I export my database with this command in a terminal Ubuntu :

/usr/bin/pg_dump --host localhost --port 5432 -E UTF-8 --format plain --verbose --username "odoo"  --format plain  --file $NOMDUFICHIER $DATABASE

During this process, I get many error of this kind :

« error: relation "account_invoice_cancel" already exists »

Can I avoid this error?

Thanks

 

Double check your script. That output looks like it is doing a restore.

john5000
on 11/13/14, 5:07 PM
0

Pascal Tremblay

--Pascal Tremblay--
1312
| 5 2 7
Alma, Canada
--Pascal Tremblay--


Pascal Tremblay
On 11/14/14, 5:07 AM

My backub works now. It was a user problem. Here is my script if somebody need it.

<pre>#!/bin/bash

clear

DATABASE="lapagept7nov"
NOW=$(date +"%m-%Y")
NOMDUFICHIER="/home/flooder/Bureau/odoo_mensuel_$DATABASE_$NOW.sql"

NEWDB="odoo_mensuel_$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.mensuel.log
echo
echo "3) Préparation de la sauvegarde de la base de données Odoo... "


export PGPASSWORD="lsdls"
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.mensuel.log

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.mensuel.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.mensuel.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.mensuel.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.mensuel.log


echo
#2>>/home/flooder/Programmes/log/odoo.db.backup.mensuel.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.mensuel.log)
echo "   + le fichier journal à envoyer à une taille : $FILESIZE octets"
sendEmail -f pt@lapagept.com -t pt@lapagept.com -u "Sync PT - mensuel - 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.mensuel.log
exit

</pre>

 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 11/12/14, 8:09 AM
Seen: 982 times
Last updated: 3/16/15, 8:10 AM