通过服务器定时任务实现postgresql异库表之间的数据同步

postgresql10以下不支持不同实例的跨库表,可以通过psql客户端+系统定时任务实现类似功能。

sql1="truncate table table_app"
sql2="select wp.id as app_id, pv.id as version_id, pv.download as url, 'cc' as check_type from table_app"

echo "$(date "+%Y%m%d %H:%M") Begin sync game data from prd db to dev db !"
psql -h psql -h 127.0.0.1 -p 5432 -U postgres -d xxxx_content -c "$sql1"
psql -h db.pg.xxxx.com -p 3433 -d xxxx_content -U postgres -c "copy ($sql2) to stdout " | psql -h 127.0.0.1 -p 5432 -U postgres -d xxxx_content -c "copy temp_check_crack_game_cc from stdin"
echo "sync done!"

 

你可能感兴趣的:(Postgresql,Centos,Linux)