waynedunkley
10/26/2016 - 7:15 AM

Dump and Restore Database

Dump and Restore Database

// Create a database dump, excluding ownership
sudo -u postgres pg_dump -Ox [old_database_name] > [backup_name]

// Restore Database to NEW database
sudo -u postgres psql [new_database_name] < [backup_name] 


// Alter Permissions
ALTER DATABASE [database_name] OWNER TO [user];

// Select Database
\c centralpark_staging;

// Fix Permissions
GRANT ALL ON ALL TABLES IN SCHEMA public to [user];
GRANT ALL ON ALL SEQUENCES IN SCHEMA public to [user];
GRANT ALL ON ALL FUNCTIONS IN SCHEMA public to [user];