I'm trying to run a cron job in ubuntu server to backup my database every day.
so Im using this cmd:
sudo -i -u postgres && pg_dump -Fc DbName > DbName_backup.dump && ... && ... && ...
the problem I have is that you can not switch user and run command in a single statement, it never works.
I have to call sudo -i -u postgres
then in another statement call pg_dump -Fc DbName > DbName_backup.dump && ... && ... && ...
But I want it to work in a single statement.