Backup databases

Hi,
I need some help and some advices , it’s the first time for me to restore data from server1 to server2, the story that I have trytond version 6 with some databases on server Number 1, now for some reasons, we will use another server so I will reinstall the trytond and everything in new, so I need to backup of the modules with the last modifications and all the data I did and the databases to the server Number 2 , so I need some advices what are the best command lines for ,the backup and restore to don’t waste any data , as I want to do the backup table by table also , any advice will be appreciated and any other advice will be considered before go to server Number2( server will not be existed in future): thanks in advance for all.

You need to dump all the data of your database with pg_dump and use pg_restore to restore them on the other server.
You also need to copy all the files create in the [database] path on the other server.
And you need to reinstall the same version of each Tryton packages and configure trytond the same way (mainly using a copy of the current configuration but updated to the new server).

Hi Mr.ced; i did’nt get you well about this instruction ? which files u mean ? do you mean the backup files( .dump) that i will restore then on the other server or what exactly ?

Tryton stores some files like the attachment in the filesystem in the [database] path directory. Those files must also be transferred.

If your database is PostgreSQL, at least under linux it is as simple as doing:

pg_dumpall -U postgres > pg_database.sql

but if like me you are interested in a personalized backup with date and time, you can use a script:

#! /bin/bash
cd
DIR="~/Backup"
DATE_TIME=`date +%F`--[`date +%I`H_`date +%M`M]
BACKUP=$DIR/BACKUPDB-$DATE_TIME.sql
pg_dumpall -U postgres > $BACKUP

and restore in the new postgresql system with a similar line where it changes according to the date and time at the end, adding the verification using a log in the second line:

psql -U postgres < BACKUPBD-2024-06-29--[02H_19M].sql > pg_mibd.log 2>&1
grep -i error pg_mibd.log

As Ced already mentioned, it is necessary to make the adjustments in the configuration files:

logging.conf
trytond.conf
trytond

as well as the attachment directories and their contents, as well as the custom templates.

For me, this has been something that at the time brought me very tough challenges with many headaches, as well as some disasters, but by researching, reading and thanks to external backups I was able to solve it without further damage.