Here are the steps you can follow to migrate a PostgreSQL database from CentOS to Rocky Linux:
-
Install PostgreSQL on Rocky Linux: You will need to install PostgreSQL on your Rocky Linux system if it is not already installed. You can do this using the package manager for your Linux distribution.
-
Stop the PostgreSQL service on CentOS: You will need to stop the PostgreSQL service on your CentOS system to ensure that the data is not modified during the migration process. You can do this using the
systemctl
command:
systemctl stop postgresql
- Create a backup of the PostgreSQL data: You will need to create a backup of the PostgreSQL data on your CentOS system to ensure that you have a copy of the data that you can restore on Rocky Linux. You can use the
pg_dump
command to create a backup of the data:
pg_dump -U username -W -Fc database_name > database_name.dump
- Transfer the backup file to Rocky Linux: You will need to transfer the backup file to your Rocky Linux system. You can use a tool like
scp
to copy the file from CentOS to Rocky Linux:
scp database_name.dump username@rocky_linux_server:/path/to/destination
- Restore the backup on Rocky Linux: You can use the
pg_restore
command to restore the backup file on your Rocky Linux system:
pg_restore -U username -W -d database_name database_name.dump
- Start the PostgreSQL service on Rocky Linux: Once the data has been restored, you can start the PostgreSQL service on your Rocky Linux system:
systemctl start postgresql
I hope this helps! Let me know if you have any questions.