add postgres backup script
This commit is contained in:
		
							parent
							
								
									493be87743
								
							
						
					
					
						commit
						0a572ac99a
					
				
					 2 changed files with 7 additions and 0 deletions
				
			
		
							
								
								
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -1,2 +1,3 @@
 | 
				
			||||||
/data
 | 
					/data
 | 
				
			||||||
/.env
 | 
					/.env
 | 
				
			||||||
 | 
					/backup
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										6
									
								
								backup.sh
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										6
									
								
								backup.sh
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
					@ -0,0 +1,6 @@
 | 
				
			||||||
 | 
					#!/bin/sh
 | 
				
			||||||
 | 
					time=$(date +"%Y-%m-%dT%H:%M:%S%z")
 | 
				
			||||||
 | 
					dir=backup
 | 
				
			||||||
 | 
					[ -d "${dir}" ] || mkdir -p "${dir}"
 | 
				
			||||||
 | 
					docker compose run --rm -u postgres keycloak_db sh -c 'PGPASSWORD=$POSTGRES_PASSWORD pg_dump -h keycloak_db -p 5432 -U $POSTGRES_USER keycloak' > "${dir}/${time}.sql"
 | 
				
			||||||
 | 
					# to restore: pg_restore -d newdb db.dump
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue