sql

size

SELECT pg_size_pretty( pg_database_size('dbname') );
SELECT pg_size_pretty( pg_total_relation_size('schemaname.tablename') );

backup and restore

echo localhost:5432:dbname:username:password > ~/.pgpass
chmod 600 ~/.pgpass
pg_dump -U postgres