PostgreSQL: Backup and Restore DB
Posted . Visible to the public.
Backup:
$ pg_dump -U {user-name} {source_db} -f {dumpfilename.sql}
Restore:
$ psql -U {user-name} -d {desintation_db}-f {dumpfilename.sql}
Related cards:
MySql: Backup and Restore DB
backup: # mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
restore:# mysql -u root -p[root_password] [database_name] < dumpfilename.sql
Mongo DB Querying
Count number of records in array:
db.data_records.count( { dataset_id: { $in: [ 2509, 2224, 2128, 2145, 2472, 2249 ] } } )
Count number of records NOT in array:
db.data_records.count( { dataset_id: { $nin: [ 2509, 2224, 2128, 2145, 2472, 2249...
MySQL: Check size of DB
SELECT table_schema 'DB Name',
round(Sum(data_length + index_length) / 1024 / 1024, 1) 'DB size in MB'
FROM information_schema.tables
GROUP BY table_schema;
MySQL: Database Size
SELECT table_schema "Data Base Name",
sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB",
sum( data_free )/ 1024 / 1024 "Free Space in MB"
FROM information_schema.TABLES
GROUP BY table_schema ;
Linux: Compress and Archive Directory
tar -zcvf archive-name.tar.gz directory-name
The resulting .tar.gz file is actually the product of two different things, tar basically just packages a group of files into a single file bundle but doesn’t offer compression on it’s own, thus t...
Posted by Luis Romero to Custom Exposure (2015-06-10 20:59)