0

I'm running a NAS server with an SD card mounted as / and RAID-1 storage mounted under /media/hdd. /etc folder is on SD card. PostgreSQL data folder is on the RAID-1 disk.

/-+
  +- etc
  |  +- postgres
  |     +- 10
  |        +- mycluster 
  |
  +- media
     |
     +- hdd
        +- pgsql
           +- data
              +- mycluster

If I want to move RAID-1 disks to a different box, what is the correct way to re-create a PostgreSQL cluster using exiting data folder? Let's assume I stopped the cluster, shutdown the system, took out hard disks and attached them to another box. Can I create a new cluster on that box using the existing data folder on the attached hard disks?

Thank you in advance.

1 Answer 1

1

Yes, that is no problem, as long as

  • you are using the same major version of PostgreSQL on the new machine

  • PostgreSQL was built in the same way

  • both machines have the same architecture and operating system version (the version is relevant because it might affect the collations, changing versions requires a REINDEX)

Running PostgreSQL on a NAS file system is dangerous, because many NAS implementations are not reliable.

3
  • What is the correct way to do that? when I run sudo pg_createcluster 10 mycluster -d /media/hdd/mycloud/pgsql/mycluster I get Configuring already existing cluster (configuration: /etc/postgresql/10/mycluster, data: /media/hdd/mycloud/pgsql/mycluster, owner: 110:115) Error: move_conffile: required configuration file /media/hdd/mycloud/pgsql/mycluster/postgresql.conf does not exist
    – Y2i
    Commented Jun 26, 2019 at 6:27
  • Looks like the dreaded Debian packages. Just create a new cluster (with the same major version), stop the server, remove the data directory, replace it with your data directory, replace the configuration files (which are somewhere under /etc on Debian) and start the server. Commented Jun 26, 2019 at 8:57
  • Thank you, it worked!
    – Y2i
    Commented Jun 26, 2019 at 15:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.