If you want toTo automate this on a schedule you could put it in the user's contrabcrontab. Cron jobs won't get the full environment though, but it it might be better to put all the env variables you need in the script itself anyways.
To edit the user's crontab:
sudo crontab -u postgres -e