Project

General

Profile

« Previous | Next » 

Revision 13262

lib/sh/db.sh: added pg_ctl(), pg_snapshot()

View differences:

trunk/lib/sh/db.sh
350 350
pg_export_table_no_header "$@"
351 351
}
352 352

  
353
## backups
354

  
353 355
pg_dump() # usage: database={...|} [schema=...] [struct=1 | data=1] [owners=1] \
354 356
# [compress=1] [create_schema=] [users=1] pg_dump [opts...] >out
355 357
# database='': entire cluster
......
387 389
	fi
388 390
}
389 391

  
392
## DB structure
393

  
390 394
pg_schema_exists() # usage: schema=... pg_schema_exists
391 395
{
392 396
	echo_func; : "${schema:?}"; mk_schema_esc
......
407 411
ignore_e=3 log++ stderr_matches psql <<<"SELECT NULL FROM $table_esc LIMIT 0"
408 412
}
409 413

  
414
## server admin
415

  
416
pg_ctl() # usage: pg_ctl {start|stop|restart|...}
417
{
418
	echo_func
419
	sudo service postgresql "$@"
420
}
421

  
422
pg_snapshot() # usage: [live=] [from=...] [to=...] pg_snapshot
423
{
424
	echo_func; kw_params from to; local from="${from:-/var/lib/postgresql}"
425
	ctl=pg_ctl db_snapshot
426
}
427

  
410 428
fi

Also available in: Unified diff