notes/postgres/move_data_directory.md
2022-09-22 11:55:39 -04:00

15 lines
508 B
Markdown

https://www.digitalocean.com/community/tutorials/how-to-move-a-postgresql-data-directory-to-a-new-location-on-ubuntu-18-04
copy the data
`sudo rsync -av /var/lib/postgresql /target_dir`
rename original as a backup
`sudo mv /var/lib/postgresql/10/main /var/lib/postgresql/10/main.bak`
point postgres to the new data directory
`sudo vim //etc/postgresql/14/main/postgres.conf`
` data_directory = '/mnt/volume_nyc1_01/postgresql/10/main'`
remove the old data
`sudo rm -Rf /var/lib/postgresql/10/main.bak`