exec find /path/to/bak -type f -mtime +10 | xargs rm -rf set timeout 30 set date [clock format [clock seconds] -format {%Y-%m-%d}] set channel [open "/path/to/log/db_bak.log" w] set devfile $date\_dev.dump puts $channel "$date backup dev db start..." spawn pg_dump -h [host] -U [db user] -d [db name] -p 5432 -x -Fc -f /path/to/bak/$devfile
expect "*口令:" send "[db pwd]\r" expect eof set date2 [clock format [clock seconds] -format {%Y-%m-%d %H:%M:%S}] puts $channel "$date2 backup dev db end!"
|