Skip to main content

Posts

Showing posts with the label postgresql

PostgreSQL: Scheduler to take db backup every two hours

Hi, Today we are going to write a scheduler to take PostgreSQL db dump every two hours in ubuntu OS. 1. Create a folder called backup in your home directory where we are going to store all the dump files. 2. Because it's cron script so can provide password at runtime, we are going to store required details in ~/. pgpass file in following format hostname:port:database:username:password localhost:5432:mydb:user1:test123 don't forget to change it's permission to 0600 ( chmod 0600 ~/.pgpass ) Note: You can change localhost with Server IP if you have 3. Create a file to write script for db backup. Let's create it in home directory itself and call it db_backup.sh Add following command to the file. pg_dump -d mydb -h localhost -p 5432 -U user1 -w  | gzip > /home/ubuntu/backup/$(date +%Y-%m-%d-%H:%m:%s).psql.gz It will save the dump file with date and time as name. e.g  2017-09-16-07:09:1505546517.psql.gz Don't forget to make db_backup.sh ...

Postgres/Django: could not load library postgis-2.1.so

If you are getting an error like this after PostgreSQL update: ERROR:  could not load library "/usr/local/Cellar/postgresql/9.5.6/lib/postgis-2.2.so": dlopen(/usr/local/Cellar/postgresql/9.5.6/lib/postgis-2.2.so, 10): Library not loaded: /usr/local/lib/libCGAL.10.dylib   Referenced from: /usr/local/lib/libSFCGAL.1.dylib   Reason: image not found  or of library libspatialite Run following command brew reinstall sfcgal --build-from-source    brew reinstall libspatialite --build-from-source I hope it will fix your issue. Thanks!!!! Enjoy Programming!!! :)