# !/bin/bash # Postgresql db backup script dbname="dbname" now="$(date +'%Y%m%d%H%M')" target="/path/to/backup/$dbname.$now.dump" echo "dumping $dbname to $target.." pg_dump -U postgres "$dbname" > "$target" # restore dump # psql dbname < yourbackup.sql # username will be prompted here # hence manual intervention is still required # for full automation, consider integrate this # with autofill_password.sh echo "DONE"