A short memo how to backup any PostgreSQL database:
In .pgpass
(you should keep this file protected):
#hostname:port:database:username:password localhost:*:netbox:netbox:VeRY_Secret
netbox-db-backup.sh
:
#!/bin/bash DATETIME=`date +%Y%m%d-%H%M` MAXDAYS=45 pg_dump "host=localhost user=netbox dbname=netbox" | gzip > netbox-dump-$DATETIME.sql.gz find . -name netbox-dump-*.sql.gz -mtime +$MAXDAYS -exec rm {} \;
That will also find and delete backup files older than MAXDAYS.