Blame

4cd688 Hargata Softworks 2024-02-09 04:59:13 1
# Postgres
2
3
For users that desire additional scalability for their backend, LubeLogger now supports a PostgreSQL backend.
4
5
## Configuration
6
24f6c5 Hargata Softworks 2024-09-27 00:48:20 7
To configure LubeLogger to use PostgreSQL, you must have at least one database for lubelogger to use. On LubeLogger versions newer than 1.3.5, the app schema will be automatically created, on previous versions you will need to manually create the schema.
4cd688 Hargata Softworks 2024-02-09 04:59:13 8
2b40a9 DESKTOP-T0O5CDB\DESK-555BD 2024-09-20 15:19:12 9
![](/Advanced/Postgres/a/image-1726781278694.png)
4cd688 Hargata Softworks 2024-02-09 04:59:13 10
28878c Hargata Softworks 2024-02-09 22:03:09 11
Once that is done, simply inject the environment variable `POSTGRES_CONNECTION` with your connection string, example:
4cd688 Hargata Softworks 2024-02-09 04:59:13 12
13
```
14
Host=<yourserveraddress:port>;Username=<yourusername>;Password=<yourpassword>;Database=<databasename>;
15
```
16
17
LubeLogger will then automatically create the tables it needs, all records will then be saved and loaded from Postgres tables from now on.
18
19
## Backups
20
21
Once you have switched over to Postgres, LubeLogger's built in and backup function will only back up images, documents, and the server config. You are responsible for maintaining backups of the DB records.
22
23
## Database Migration
24
91ba3d Hargata Softworks 2024-02-09 22:02:05 25
A tool is provided to ease the migration process between LiteDB and Postgres. This tool can be found at the `/migration` endpoint and is only accessible when a Postgres connection is provided.
26
2b40a9 DESKTOP-T0O5CDB\DESK-555BD 2024-09-20 15:19:12 27
![](/Advanced/Postgres/a/image-1726781283739.png)
d564c4 Hargata Softworks 2024-02-09 22:33:03 28
29
### Importing to Postgres
30
31
To transfer all your existing data from LiteDB to Postgres:
32
1. Create a backup using the "Make Backup" feature in the Settings tab.
33
2. Extract the zip file.
34
3. You should see a folder named "data" in the extracted folder
35
4. Inside the data folder will be a .db file named `cartracker.db`
36
5. Navigate to the Database Migration tool
37
6. Click "Import to Postgres"
38
7. Select the `cartracker.db` file
39
8. Your data will be imported into your Postgres DB, and you may double check that the DB has been imported successfully using a Postgres DB Administration Tool.
40
41
### Exporting from Postgres
42
43
In the event that you need to transfer all your data back onto a LiteDB database file from Postgres, you may do so using the Database Migration tool:
44
1. Navigate to the Database Migration Tool
45
2. Click "Export from Postgres"
46
3. Extract the downloaded zip file and you should find `cartracker.db` in it.
47
4. Create a backup using the "Make Backup" feature in the Settings tab.
48
5. Extract the zip file.
49
6. You should see a folder named "data" in the extracted folder, if not, create it.
50
7. Place `cartracker.db` inside the "data" folder
51
8. Re-zip the extracted folder
52
9. Restore the backup using the "Restore Backup" feature in the Settings tab.
53
10. Make sure you remove the PostgreSQL connection from the environment variables so that all future changes will be saved in LiteDB.