1. 定时自动备份表
vim baktable.sh source /home/pg12/.bash_profile
DATE=`date "+%Y%m%d%H%M%S"`
PGDIR=/4T/postgresql/pg12/pgdir101
PGARCH=/4T/postgresql/pg12/archive输人密码
export PGPASSWORD='!@#Bds#pg¥%……'#备份表psql -h 192.168.18.101 -U postgres -d postgres -c "create TABLE smp.smp_task_log_info$DATE as select * from smp.smp_task_log_info;"----------------------------------------------------------------------------------
crontab -e
30 19 * * * su - pg12 -c /4T/postgresql/pg12/scripts/baktable.sh
---------------------------------------------------------------------------------