Add support for arbitrary port when downloading Postgres database
This commit is contained in:
		
							parent
							
								
									6f0b1318d5
								
							
						
					
					
						commit
						11db1579c4
					
				
					 1 changed files with 5 additions and 2 deletions
				
			
		|  | @ -143,7 +143,7 @@ def drop_db(name, checkfirst=True): | ||||||
|         sudo('sudo -u postgres dropdb {0}'.format(name), shell=False) |         sudo('sudo -u postgres dropdb {0}'.format(name), shell=False) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def download_db(name, destination=None): | def download_db(name, destination=None, port=None): | ||||||
|     """ |     """ | ||||||
|     Download a database from the "current" server. |     Download a database from the "current" server. | ||||||
|     """ |     """ | ||||||
|  | @ -151,7 +151,10 @@ def download_db(name, destination=None): | ||||||
|         destination = './{0}.sql.gz'.format(name) |         destination = './{0}.sql.gz'.format(name) | ||||||
|     run('touch {0}.sql'.format(name)) |     run('touch {0}.sql'.format(name)) | ||||||
|     run('chmod 0666 {0}.sql'.format(name)) |     run('chmod 0666 {0}.sql'.format(name)) | ||||||
|     sudo('sudo -u postgres pg_dump --file={0}.sql {0}'.format(name), shell=False) |     sudo('sudo -u postgres pg_dump {port} --file={name}.sql {name}'.format( | ||||||
|  |         name=name, | ||||||
|  |         port='--port={}'.format(port) if port else '', | ||||||
|  |     ), shell=False) | ||||||
|     run('gzip --force {0}.sql'.format(name)) |     run('gzip --force {0}.sql'.format(name)) | ||||||
|     get('{0}.sql.gz'.format(name), destination) |     get('{0}.sql.gz'.format(name), destination) | ||||||
|     run('rm {0}.sql.gz'.format(name)) |     run('rm {0}.sql.gz'.format(name)) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lance Edgar
						Lance Edgar