Использование textarea
<textarea name="textarea" style="width:250px;height:150px;"></textarea>
не оставляет места между открывающими и закрывающими тегами Или Else Это оставит несколько пустых строк или пробелов.
Поскольку у вас все равно есть права суперпользователя, вы можете поместить эти команды в crontab пользователя postgres следующим образом:
sudo su postgres
crontab -e
, а затем поместите туда команды pg_dump / Vacuumdb.
Возможно, ваша переменная среды не установлена в cron.
В обычном сеансе вы, вероятно, определили эти переменные:
PG_PORT
PG_HOST
PG_DATABASE
PG_USERNAME
PG_PASSWORD
Добавьте «env» в сценарий yout.
I have a dynamic bash script that backs up all the databases on the server. It gets a list of all the databases and then vacuums each DB before performing a backup. All logs are written to a file and then that log is emailed to me. This is something you could use if you want.
Copy the code below into a file and add the file to your crontab. I have setup my pg_hba.conf to trust local connections.
#!/bin/bash
logfile="/backup/pgsql.log"
backup_dir="/backup"
touch $logfile
databases=`psql -h localhost -U postgres -q -c "\l" | sed -n 4,/\eof/p | grep -v rows\) | grep -v template0 | grep -v template1 | awk {'print $1'}`
echo "Starting backup of databases " >> $logfile
for i in $databases; do
dateinfo=`date '+%Y-%m-%d %H:%M:%S'`
timeslot=`date '+%Y%m%d%H%M'`
/usr/bin/vacuumdb -z -h localhost -U postgres $i >/dev/null 2>&1
/usr/bin/pg_dump -U postgres -i -F c -b $i -h 127.0.0.1 -f $backup_dir/$i-database-$timeslot.backup
echo "Backup and Vacuum complete on $dateinfo for database: $i " >> $logfile
done
echo "Done backup of databases " >> $logfile
tail -15 /backup/pgsql.log | mailx youremail@domain.com