-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): migration postgres 14 to 17
- Loading branch information
Showing
3 changed files
with
71 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
Here is the corrected and formatted version of your migration process: | ||
**The goal**: Migrate PostgreSQL from 14 to 17 | ||
|
||
### Steps: | ||
|
||
1. **Connect via SSH to the instance** | ||
```bash | ||
ssh root@{ip} | ||
``` | ||
2. **Install PostgreSQL 17** | ||
```bash | ||
sudo apt install curl ca-certificates | ||
sudo install -d /usr/share/postgresql-common/pgdg | ||
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc | ||
|
||
sudo sh -c 'echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' | ||
|
||
sudo apt update | ||
|
||
sudo apt -y install postgresql | ||
``` | ||
|
||
3. **Create a backup of the current database** | ||
```bash | ||
pg_dump -d 'postgresql://datainclusion:{password}@172.17.0.1:5432/datainclusion' -Fc -f migrate_14_to_17.sql | ||
``` | ||
|
||
4. **Import the dump locally** | ||
Transfer the backup file to your local machine: | ||
|
||
```bash | ||
scp root@{ip}:/root/migrate_14_to_17.sql ~/data | ||
``` | ||
|
||
5. **Stop the instance** | ||
Stop the running services using Docker Compose: | ||
|
||
```bash | ||
docker compose stop | ||
``` | ||
|
||
6. **Clean the data folder** | ||
Remove all the existing data in the target database container: | ||
|
||
```bash | ||
docker compose run target-db bash | ||
rm -rf /var/lib/postgresql/data/* | ||
``` | ||
|
||
7. **Update the PostgreSQL version** | ||
Change the version in your Docker configuration (e.g., in the `docker-compose.yml` file). | ||
|
||
8. **Access the new PostgreSQL container** | ||
Enter the PostgreSQL container: | ||
|
||
```bash | ||
docker compose exec datawarehouse bash | ||
``` | ||
|
||
9. **Run the migration** | ||
Restore the backup to the new PostgreSQL version: | ||
|
||
```bash | ||
pg_restore --no-owner -Fc /var/lib/postgresql/migrate/migrate_14_to_17.sql -d 'postgresql://datainclusion:{password}@172.17.0.1:5432/datainclusion' -j 8 -v | ||
``` | ||
|
||
10. **Deploy the updated environment** | ||
After the migration, deploy the necessary changes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters