Moving the database¶
This section describes how to move the physical location of the database files from one location to another (e.g. if you run out of disk space).
Stop the AiiDA daemon and back up your database.
Find the data directory of your postgres installation (something like
The best way is to become the postgres UNIX user and enter the postgres shell:psql SHOW data_directory; \q
If you are unable to enter the postgres shell, try looking for the
data_directoryvariable in a file
Stop the postgres database service:service postgresql stop
Copy all files and folders from the postgres
data_directoryto the new location:cp -a SOURCE_DIRECTORY DESTINATION_DIRECTORY
-awill create a directory within
DESTINATION_DIRECTORY, e.g.:cp -a OLD_DIR/main/ NEW_DIR/
NEW_DIR/main. It will also keep the file permissions (necessary).
The file permissions of the new and old directory need to be identical (including subdirectories). In particular, the owner and group should be both
postgres(except for symbolic links in
server.keythat may or may not be present).
If the permissions of these links need to be changed, use the
chownto avoid changing the permissions of the destination of the links. In case you have changed the permission of the links destination by mistake, they should typically be (beware that this might depend on your actual distribution!):-rw-r--r-- 1 root root 989 Mar 1 2012 /etc/ssl/certs/ssl-cert-snakeoil.pem -rw-r----- 1 root ssl-cert 1704 Mar 1 2012 /etc/ssl/private/ssl-cert-snakeoil.key
data_directoryvariable in your postgres configuration file (e.g.
/etc/postgresql/9.6/main/postgresql.conf) to the new directory.
Restart the database daemon:service postgresql start
Finally, check that the data directory has indeed changed:
psql SHOW data_directory; \q
and try a simple AiiDA query with the new database.
If everything went fine, you can delete the old database location.