Remove diagram script; Add postgres-update script
This commit is contained in:
		
							parent
							
								
									1cb92e3825
								
							
						
					
					
						commit
						063b422426
					
				
					 3 changed files with 39 additions and 121 deletions
				
			
		
							
								
								
									
										38
									
								
								_utils/postgres-update.sh
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								_utils/postgres-update.sh
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,38 @@
 | 
			
		|||
#!/usr/bin/env sh
 | 
			
		||||
# shellcheck disable=SC2162
 | 
			
		||||
 | 
			
		||||
printf "\nWARNING: This script is work in progress and not tested yet. "; read
 | 
			
		||||
printf "\nStep 1: Backup done? "; read
 | 
			
		||||
 | 
			
		||||
printf "\nStep 2: Stop services - continue? "; read
 | 
			
		||||
systemctl stop postgresql.service
 | 
			
		||||
systemctl status postgresql.service --no-pager
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
printf "\nStep 3: Create directories and move data - continue? "; read
 | 
			
		||||
[ -d /var/lib/postgres/data ] && mv /var/lib/postgres/data /var/lib/postgres/olddata
 | 
			
		||||
mkdir /var/lib/postgres/data /var/lib/postgres/tmp
 | 
			
		||||
chown postgres:postgres /var/lib/postgres/data /var/lib/postgres/tmp
 | 
			
		||||
cd /var/lib/postgres/tmp || exit
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
printf "\nStep 4: Init new database - continue? "; read
 | 
			
		||||
sudo -u postgres initdb -D /var/lib/postgres/data --locale=en_US.UTF-8 --encoding=UTF8
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
printf "\nStep 5: Upgrade to new version - continue? "; read
 | 
			
		||||
printf "Old version: "; read -r pg_version
 | 
			
		||||
pg_path="/opt/pgsql-$pg_version/bin"
 | 
			
		||||
[ -d "$pg_path" ] || exit
 | 
			
		||||
sudo -u postgres pg_upgrade -b "$pg_path" -B /usr/bin -d /var/lib/postgres/olddata -D /var/lib/postgres/data
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
printf "\nStep 6: Restart database - continue? "; read
 | 
			
		||||
systemctl start postgresql.service
 | 
			
		||||
systemctl status postgresql.service --no-pager
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
printf "\nStep 7: Cleanup - continue? "; read
 | 
			
		||||
sudo -u postgres vacuumdb --all --analyze-in-stages
 | 
			
		||||
rm -r /var/lib/postgres/olddata /var/lib/postgres/tmp
 | 
			
		||||
printf "\nDone. "; read
 | 
			
		||||
		Reference in a new issue