When the Odoo database grow larger to a certain extend, download from the web manager will often impossible or erroneous.
Getting a PSQL Database Backup from Server
1) Switch to the postgres user using the following command:
su – postgres
2) Create a database backup file using the following command:
pg_dump original_database_name > backup_file_name.sql
3) Once the backup is done, you can compress the file for faster downloads if necessary, with the following command:
zip -r zip_file_name.zip original_file_name
4) Now, got to the “/var/lib/postgresql” folder using FileZilla to download the .zip or .sql/.dump fie.
Remember to delete these extra files from the server once you’re done downloading, as this will only occupy extra space.
After downloading the file, you can follow the next section to restore the database locally.
Restoring a PSQL database on Windows 10/11 through CMD
1. Locate the local Postgres installation, the path is usually “C:\Program Files\PostgreSQL\12\bin”.
2. Open CMD inside the “bin” folder.
3. Create a new database by using the following command:“created -U username new_database_name”In this case, the username will be the Postgres access user (commonly odoo or your system’s username)
4. After creating a new database, locate your .sql/.dump file
Then use the following command to restore the database locally.
psql -U username -d test_db -f "Path\to\dump\or\sql\file"
Then just enter your password and the database will start restoring
You’ll regain access to the terminal once the database has restored successfully. The database should be accessible in Odoo now.
Kommentare